This sample shows how to use the perl-ldap module to extend the schema of eDirectory. This sample shows an example of adding an attribute type and an object class. Notice the similarities between these calls and a standard LDIF. Also make sure the oids are valid before trying this sample.
#!perl
use Net::LDAP;
use Net::LDAP::LDIF;
use File::Path qw(rmtree);
use File::Basename qw(basename);
print "Content-type: text/html\n\n";
$HOST = '137.65.138.159';
$PORT = 389;
$PASSWD = 'novell';
$BASEDN = "o=novell";
$ADMIN= "cn=admin,o=novell";
#connect to the server
until($ldap = Net::LDAP->new($HOST, port => $PORT)) {
die "Can not connect to ldap://$HOST:$PORT/" if ++$count > 10;
sleep 1;
}
$r = $ldap->bind($ADMIN, password => $PASSWD, version=>3);
die $r->error if $r->code;
#This information should be formatted just like an LDIF file would be. Make sure all information is correct. These sample
# oids may not work.
$objectclass = "(1.3.6.1.1.1.2.715.1 NAME 'MyObjectClass' DESC 'My Test Object Class' AUXILIARY MAY (groupMembership \$ Surname))";
$r = $ldap->modify("cn=schema", add => { objectClasses => $objectclass });
print $r->error if $r->code;
$attributetype = "(1.3.6.1.1.1.1.1.25.1 NAME 'MyAttributeType' DESC 'My Test Attribute Type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.25 SINGLE-VALUE)";
$r = $ldap->modify("cn=schema", add => { attributetypes => $attributetype });
print $r->error if $r->code;
print "Schema updated";
$ldap->unbind;
© 2008 Novell, Inc. All Rights Reserved.