Novell is now a part of Micro Focus

Change United States, English

Login

Using PHP, how would I check to see...

Articles and Tips: qna

01 Jun 2003


Q.

Using PHP, how would I check to see if an object class has an auxiliary class? If it doesn't, I would like to add an auxiliary class to the object class and then populate it with a value.

A.

To see if an object has an auxiliary class, you need to get the object and see if the objectclass attribute has the auxiliary class that you are interested in. There are good search examples on the PHP website at http://www.php.net/ldap.

Perform a normal search and make sure you have "objectclass" as one of the attributes to return. The objectclass attribute is multi-valued, so you will need to enumerate the list of them and see if your class is among them. If it is not, the following code shows how to add the posixaccount auxiliary class.

//add the posixaccount aux class and fill in its values
$entry['objectclass'][0] = "posixaccount";
$entry['gidnumber'] = 1000;
$entry['uidnumber'] = $uidNumber;
$entry['homedirectory'] = "/home/generalusers";
$entry['gecos'] = $userName;
$entry['loginshell'] = "/bin/bash";
$res = ldap_mod_add($conn, $userDN, $entry);

* 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 2025 Micro Focus or one of its affiliates