<?php

use Adldap\Laravel\Facades\Adldap;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    echo 'aaaaaaaaaaaaaa';
//    return view('welcome');
});


Route::get('/ad', function () {
    $ad = new \Adldap\Adldap();

//    $config = [
//        'domain_controllers' => ["172.20.100.201"],
//        'base_dn'=>'ou=Users_hoto,dc=hoto,dc=test',
//        'admin_username'=>'hcmadmin',
//        'admin_password'=>'hcmadmin123' hoto.test\hcmadmin  密码:hcmadmin123
//    ];
//    echo "new obj...\r\n";
//    var_export($ad);
    $config = [
        'hosts' => ["172.20.100.201"],
        'base_dn'=>'ou=Users_hoto,dc=hoto,dc=test',
        'username'=>'hoto\hcmadmin',
        'password'=>'hcmadmin123'
    ];
    $ad->addProvider($config);
//    var_export($ad);
//    echo "new obj2...\r\n";
    try{
//        'default','hoto\hcmadmin','hcmadmin123'
        $provides = $ad->connect();
        $result = $provides->search()->ous()->find('IT发展部');
        var_export($result);die;
    }catch (Exception $e) {
        echo $e->getMessage();
    }
});


Route::get('/ad2','LdapController@handle');
Route::post('/syncAd','LdapController@handle');