import ldap
def __create( handle, dn, attrs ):
if not handle:
return False
handle.add_s( dn, attrs )
# Example - this code will create an object of the type posixAccount.
attrs = []
attrs.append( ("CN","cn=jdoe,o=users") )
attrs.append( ("Surname","Doe") )
attrs.append( ("objectClass","inetOrgPerson") )
attrs.append( ("objectClass","posixAccount") )
attrs.append( ("homeDirectory","/home/jdoe") )
attrs.append( ("gidNumber","1234") )
attrs.append( ("uidNumber","1234") )
attrs.append( ("uid","jdoe") )
attrs.append( ("Language","ENGLISH") )
attrs.append( ("passwordAllowChange","TRUE") )
handle = __connect( "localhost", "cn=admin,o=users", "password" )
if handle:
__create( handle, "cn=jdoe,o=users", attrs )
© 2008 Novell, Inc. All Rights Reserved.