PHP » PYTHON |
login |
register |
about
|
#!/bin/bash
#import needed modules import ldap import ldap.modlist as modlist #change localhost and 389 to your host and port respectively l = ldap.initialize("ldap://localhost:389/") #change "secret" to root password and change cn and dc entries as needed try: l.simple_bind_s("cn=root,dc=example,dc=com","secret") except ldap.LDAPError, e: print 'Could not bind' dn = 'cn=member1,ou=People,dc=example,dc=com' #a dict to help build the "body" of our person #use square brackets to enclose the name of your attr (couldn't get them to show up on here) attrs = {} attrs 'objectclass' = 'needed objects' attrs 'cn' = 'member1' attrs 'uid' = 'member1' attrs 'mail' = 'member1@example.com' attrs 'gidNumber' = '100' attrs 'uidNumber' = '100' attrs 'homeDirectory' = '/home/member1' attrs 'userPassword' = 'someTempPassword' #convert our dict to nice syntax for the add-function using modlist-mosdule ldif = modlist.addModlist(attrs) #do the actual synchronous add-operation to the ldapserver l.add_s(dn,ldif) #free up some resources l.unbind_s ldap_add(PHP 4, PHP 5) ldap_add — Add entries to LDAP directory Description
bool ldap_add
( resource $link_identifier
, string $dn
, array $entry
)
Add entries in the LDAP directory. Parameters
Return ValuesReturns TRUE on success or FALSE on failure. Examples
Example #1 Complete example with authenticated bind
<?php
Notes
|
more
Recently updated
more
Most requested
more
Last requests
|