Jump to content

Active Directory with PHP Changing you DN or moving OUs


gcoleman0828

Recommended Posts

Can someone please tell me if it is possible and if so, what i should be using to have the ability within PHP to change the OU that a user resides in. i tried using ldap_mod_replace using the script below:

 

 

<?php

$ds = ldap_connect("ri-domain01"); // assuming the LDAP server is on this host

 

if ($ds) {

// bind with appropriate dn to give update access

$r = ldap_bind($ds, "CN=Authenticated User,OU=CINET,OU=Carousel Everyone,DC=CHARLESTOWN,DC=CAROUSELINDUSTRIES,DC=com", "PASSWORD");

 

// prepare data

$info["distinguishedname"] = array("CN=Easter Bunny2,OU=Disabled accounts,OU=Other Users,DC=CHARLESTOWN,DC=CAROUSELINDUSTRIES,DC=com");

//$info["sn"] = array("Jones");

 

//$info["objectclass"] = array("person");

 

// add data to directory

$r = ldap_mod_replace($ds, "CN=Easter Bunny2,OU=New_Employees,OU=Carousel Everyone,DC=CHARLESTOWN,DC=CAROUSELINDUSTRIES,DC=com", $info);

echo "User Added";

ldap_close($ds);

} else {

echo "Unable to connect to LDAP server";

}

?>

 

If i change the $info["distinguishedname"] to

$info["mail"] and put an email address in, it updates the email field, but when i try the DN, it gives me the following error...

 

Warning: ldap_mod_replace() [function.ldap-mod-replace]: Modify: Constraint violation in /var/www/Testing/LDAP/Testing/ldap_change_DN.php on line 15

User Added

 

Any info would be greatly appreciated

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.