NYCPHP Meetup

NYPHP.org

[nycphp-talk] LDAP -- trouble inserting records

Randal Rust randalrust at gmail.com
Thu Nov 16 08:18:50 EST 2006


I am working on writing the code (with PHP LDAP functions) to insert
records into a directory. I  have been working for about five hours
now, trying to insert a new organization, but to no avail. I continue
to get an error (65) from this block of code, and I cannot figure out
why. Any ideas?

	function addOrganization(){
		global $host, $user_name, $password, $ldapbase;
		$ds = ldap_connect($host);
		ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
		if($ds){
			//bind with appropriate dn to give update access
			$r = ldap_bind($ds, $user_name, $password);
			$dn = 'libkey=SP-RANDAL-LIBRARY,ou=Boston,'.$ldapbase;
			echo $dn.'<br />';
			//build test array
			$orgArray=array();
			$orgArray['objectClass']=array("top", "organization", "mlinOrganization");
			$orgArray['sadacOrganizationName'] = 'Randal Rust Library';
			$orgArray['libkey'] = 'SP-RANDAL-LIBRARY';
			//execute entry
			$r = ldap_add($ds, $dn, $orgArray);
			if(!$r){
				echo 'error - '.ldap_error($ds).'<br />';
				echo 'error - '.ldap_errno($ds).'<br />';
				}
			else {
				echo 'success - organization successfully aded to the directory.<br />';
				}
			}
		else {
			echo 'error in ds';
			}
		}

-- 
Randal Rust
R.Squared Communications
www.r2communications.com



More information about the talk mailing list