This code sample shows how to modify the schema of eDirectory in PHP via LDAP. This sample shows an example of adding an attribute type and an object class. Notice the similarities between these calls and a standard LDIF.
<?php
$server = 'localhost';
$dn = 'cn=admin,o=novell';
$pw = 'novell';
$ds=ldap_connect($server); // must be a valid LDAP server!
if ($ds) {
$r=ldap_bind($ds, $dn, $pw); // this is an simple bind
if($r) echo "ldap_bind success<br>";
/* $entry['attributetypes'] = "(1.3.6.1.1.1.1.1.25"
." NAME 'MyAttType'"
." DESC 'MyAttType Test'"
." SYNTAX 1.3.6.1.4.1.1466.115.121.1.25"
." SINGLE-VALUE)";
*/
$entry['objectClasses'] = "(1.3.6.1.1.1.2.708"
." NAME 'MyObjClass'"
." DESC 'MyObjClass Test'"
.' AUXILIARY MAY (groupMembership $ Surname))';
$r = ldap_mod_add($ds, "cn=schema", $entry);
if($r) echo "ldap_mod_add success<br>";
ldap_close($ds);
} else {
echo "<h4>Unable to connect to LDAP server</h4>";
}
?>
© 2008 Novell, Inc. All Rights Reserved.