I have the following code:
<?php
$ldapConn = ldap_connect('ldap://XXX.YYY.WWW.NNN:389');
ldap_set_option($ldapConn, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_bind( $ldapConn, 'CN=Administrador,CN=Users,DC=XXX,DC=YYY', 'PASWD');
$dn_user='CN=testLDAP,OU=empleados,OU=usuarios_XXX,DC=XXX,DC=YYY';;
$ldaprecord['cn'] = "testLDAP";
$ldaprecord['givenName'] = "testLDAP";
$ldaprecord['sn'] = "testLDAP";
$ldaprecord['sAMAccountName'] = "testLDAP";
$ldaprecord['UserPrincipalName'] = "testLDAP@XXX.com";
$ldaprecord['displayName'] = "testLDAP";
$ldaprecord['name'] = "testLDAP";
$ldaprecord['UserAccountControl'] = "544";
$ldaprecord['objectclass'][0] = 'top';
$ldaprecord['objectclass'][1] = 'person';
$ldaprecord['objectclass'][2] = 'organizationalPerson';
$ldaprecord['objectclass'][2] = 'user';
$ldaprecord['mail'] = "lkl@fh.com";
ldap_add($ldapConn, $dn_user, $ldaprecord);
ldap_unbind($ldapConn);
?>
With this code I can create a user on Active Directory , but if I use "Active Directory Users" MMC to locate the user created by this script, I can´t see this user on the OU where I created it, but I can see it from ADSI Edit in the same OU where I can´t see it in "Active Directory Users" MMC, I can search the user in the search option located in the in "Active Directory Users" MMC.
Also I can´t login with user as regular user (setting password manually)
Could it be a mistake or missing property in the ldaprecord?
I was trying again and now it works I don´t know really why. I suspect is any problem in the mmc console, the code is the same and it works without problem.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.