1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
error_reporting(E_ALL);
require ($_SERVER['DOCUMENT_ROOT']."/config/config.php");
require ($_SERVER['DOCUMENT_ROOT']."/lib/Adldap/adLDAP.php");
$options = array(
"account_suffix"=> "@paris.corp",
"base_dn" => "DC=paris,DC=corp",
"domain_controllers" => array("10.22.31.1"),
"username" => "Admin",
"password" => "123456789",
"use_ssl" => true,
"use_TLS" => false,
);
try {
$adldap = new adLDAP($options);
$adldap->connect();
} catch (adLDAPException $e) {
echo $e; exit();
}
$attributes=array(
"username"=>"André ALPHA",
"logon_name"=>"a.alpha@paris.corp",
"firstname"=>"André",
"surname"=>"ALPHA",
"company"=>"paris",
"description"=>"description",
"department"=>"Department",
"email"=>"a.alpha@google.fr",
"container"=>array("OU=toto,OU=Utilisateur,DC=paris,DC=corp","CN=ALPHA André"),
"enabled"=>1,
"password"=>"Bienvenue-2018"
);
try {
$result=$adldap->user()->create($attributes);
print_r($result);
echo "c'est fait";
}
catch (adLDAPException $e) {
echo "c'est pas fait";
echo $e;
} |
Partager