Sample Code - Modifying Attributes with LDAP and Python
Novell Cool Solutions: Feature
|
Digg This -
Slashdot This
Posted: 12 Oct 2005 |
This code snippet shows a simple function that will modify attributes of an object using LDAP and Python-LDAP.
You can also find this sample code at:
http://forge.novell.com/modules/xfref_library/detail.php?reference_id=202
Parameters
handle = a connection handle as returned by __connect
dn = string representation of the DN of the object to be modified
attrs = list of tuples that specify the changes to be made. Each tuple contains three values:
* one of ldap.MOD_ADD, ldap.MOD_DELETE, or ldap.MOD_REPLACE depending on the action desired
* string representing the schema attribute type (i.e. "instantMessagingID")
* string or list of strings representing the value(s) to add, replace, or delete. If a delete, "None" will delete all values in a multi-valued attribute.
So, a valid value for attrs could be: [ (ldap.MOD_ADD, "instantMessagingID", "babybumkins") ].
See the python-ldap documentation for more details.
Sample Code
import ldap
def __modify( handle, dn, attrs ):
if not handle:
return False
handle.modify_s( dn, attrs )
Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions. www.webwiseone.com

