All pastes #733247 Raw Edit

Mine

public text v1 · immutable
·published 2007-10-11 17:25 UTC
rendered paste body
#!/usr/bin/python

import LDAPObject

class Person(LDAPObject):
	objectClass = [ 'person', 'inetOrgPerson' ]	# All other attributes are extrapolated from LDAP schema

a = Person (base = 'ou=people,dc=test,dc=com', cn = 'Test User', uid = 'test', userPassword = 'blah' } 	# returns a new LDAP object, directy written to LDAP server
b = Person.getByDn (dn = "cn=user,ou=people,dc=test,dc=com" )		# returns an existing LDAP object, by the DN specified
c = Person.getBy (base = 'ou=people,dc=test,dc=com', cn = 'stuff')	# searches for an object in LDAP, only the first occurence is returend from base
d = Person.getBy (cn = 'stuff')						# 'base' optional
e = Person.search (base = 'ou=people,dc=test,dc=com', cn = 's*')	# returns a list of LDAP objects that match the query

a.postalAddress = "123 Drowning street"					# sets the 'postalAddress' property, directly writes back to LDAP
a.delete()								# Deletes te object from LDAP
a.attributes()								# Return a list of all LDAP attributes associated with this object