Link to home
Start Free TrialLog in
Avatar of zzman123
zzman123

asked on

PHP ldap_mod_replace throws warning

I can connect to the active directory server, bind to it and search it and all that, but when i try to use ldap_mod_replace (i am trying to give the users the ability to change their own AD passwords) it throws the following warning:
"Warning: ldap_mod_replace(): Modify: No such object in ..."

I would greatly appretiate any help.
//make the connection//
if(!$ldap_con = ldap_connect($domain_ctr)){ die("Cannot connect"); }
else { echo "<li />Connection successful ..."; }
 
//var_dump( $ldap_con );
if($ldap_bind = ldap_bind($ldap_con, $adm_user."@yponepublishing.local", $adm_pass)){
	//read user file//
	$fp = fopen($user_fl, 'r');
	
	while (($data = fgetcsv($fp, 1000, ",")) !== false) {
		
		//username, repID/
		echo "<li />".count($data);print_r($data);
		if(count($data) == 2){
			//echo "<li />";var_dump($data);
 
			$user_name = $data['0'];
			$new_pass = 'Sales'.$data['1'];
			$attr["unicodePwd"][0] = encodePassword($new_pass);
 
			//Change password/
			if(ldap_mod_replace($ldap_con, "uid=".$user_name.$dc_str, $attr)) {
				echo "<li /> ".$user_name." = Succeded";
			}else { echo "<li />".$user_name." = Failed"; }						
		}//end if 
	}//end while
		
	fclose($fp);
}//end if if($ldap_bind = @ldap_...
 
 
//close connection//
ldap_close($ldap_con);

Open in new window

Avatar of MSE-dwells
MSE-dwells
Flag of Yemen image

My gut's telling me you have to base64 encode the quoted password string but I haven't got the resources to hand right now to verify that.

I'll look further if time permits and the question remains unresolved ...
... there again, now I'm thinking that was a legacy Win2K requirement.

Heh, must stop thinking about this for the moment ... will return later as I said ...
Avatar of zzman123
zzman123

ASKER

I think the problem is on the php side and not the AD server itself.
ASKER CERTIFIED SOLUTION
Avatar of MSE-dwells
MSE-dwells
Flag of Yemen image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial