Novell is now a part of Micro Focus

I have a project that we are working...

Articles and Tips: qna

01 Jul 2003


Q.

I have a project that we are working on and I need to retrieve an attribute from the schema of a user, from a PHP program. Specifically, I need to get their GUID. I can see it with LDAP browsers, but I cannot figure out how to get it out of there. I am using an LDAP_connect command to make sure that I am logged in.

I do realize that somewhere I need to specify "cn=schema" and possibly pull the attribute out of there, but I'm not sure how to do that with PHP. Here is the code that I am using for getting the attributes that I can see:

$entry = ldap_first_entry($ds, $sr);


	$attrs = ldap_get_attributes($ds,
			$entry);


	echo $attrs["count"]." attributes
			held for this entry:<p>";


	for ($i=0; $i<$attrs["count"]; $i++)
			echo $attrs[$i]."<br>";


		echo "Closing connection";


		ldap_close($ds);


	} else

I am not sure if I need to specify in the $ds cn=schema or what.

A.

Do you want to get the schema definition for the GUID or the GUID value? If you want the value, there is no need for a cn=schema thing.

Make sure you are binding with correct credentials; otherwise, you'll not see every attribute. Also, put the ldap_close after your for() loop.

* Originally published in Novell AppNotes


Disclaimer

The origin of this information may be internal or external to Novell. While Novell makes all reasonable efforts to verify this information, Novell does not make explicit or implied claims to its validity.

© Copyright Micro Focus or one of its affiliates