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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.