|
Posted by bisi on 01/04/07 10:57
Hello
I am using php5 and trying to add users to the AD with the following
php-script, but it doesnt work. Login,... works fine but I get an
error:
"ldap_add() [function.ldap-add]: Add: Referral in
C:\wamp\www\validAdminPage.php on line 51"(line 51 is the line which
does the add). an the output "There was a problem" which is the output
if the add goes wrong.
Any ideas
THanx
CB
The script:
$ldaprdn = "admin@ville.dom";
$ldappass ="<password>";
$ds = '10.121.2.202';
$dn = "CN=jmiller,CN=Users;dc=ville,dc=dom";
$ldapport = 389;
$ldapconn = ldap_connect($ds, $ldapport)
or die("Could not connect to LDAP server.");
if ($ldapconn)
{
ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION,3);
ldap_set_option($ldapconn, LDAP_OPT_REFERRALS,0);
$ldapbind = ldap_bind($ldapconn, $ldaprdn, $ldappass);
if ($ldapbind){
$adduserAD["cn"][0] = "jmiller";
$adduserAD["samaccountname"][0] = "jmiller";
$adduserAD["objectclass"][0] = "top";
$adduserAD["objectclass"][1] = "person";
$adduserAD["objectclass"][2] = "organizationalPerson";
$adduserAD["objectclass"][3] = "user";
$adduserAD["displayname"][0] = "jemp miller";
$adduserAD["name"][0] = "jemp";
$adduserAD["givenname"][0] = "miller";
$adduserAD["sn"][0] = "Bisdorff";
$adduserAD["company"][0] ="vdl";
$adduserAD["description"][0] = "my description";
$adduserAD["mail"][0] = "jmiller@ville.dom";
$adduserAD["samaccountname"][0] = "jbisdorff";
$adduserAD["userprincipalname"][0] ="jmiller@ville.dom";
// add data to directory
$result=ldap_add($ldapconn, $dn, $adduserAD);
if ($result)
echo "User added!";
else
echo "There was a problem!";
ldap_unbind($ldapconn);
Navigation:
[Reply to this message]
|