[cvs] [Wiki] changed: ExistingLDAPHowTo
Wiki Guest
wiki at wiki.horde.org
Sun Aug 14 16:20:57 PDT 2005
guest [24.156.132.39] Sun, 14 Aug 2005 16:20:57 -0700
Modified page: http://wiki.horde.org/ExistingLDAPHowTo
New Revision: 1.15
Change log: updated example code to not always increment when we are not adding a user
@@ -108,17 +108,19 @@
$entry['uid'] = $userID;
$entry['homeDirectory'] = '/home/' . $userID;
$entry['gidNumber'] = 100;
- // get the next available uid
- $ds = @ldap_connect($GLOBALS['conf']['auth']['params']['hostspec']);
- @ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, $GLOBALS['conf']['auth']['params']['version']);
- @ldap_bind($ds, $GLOBALS['conf']['auth']['params']['binddn'], $GLOBALS['conf']['auth']['params']['password']);
- $searchResults = @ldap_search($ds, 'dc=example,dc=com', 'cn=NextFreeUnixId');
- $information = @ldap_get_entries($ds, $searchResults);
- ldap_modify($ds, 'cn=NextFreeUnixId,dc=example,dc=com', array('uidnumber' => $information[0]['uidnumber'][0] + 1));
- @ldap_close($ds);
- $entry['uidNumber'] = $information[0]['uidnumber'][0];
+ // get the next available uid and increment it if we're adding a user
+ if (isset($credentials)) {
+ $ds = @ldap_connect($GLOBALS['conf']['auth']['params']['hostspec']);
+ @ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, $GLOBALS['conf']['auth']['params']['version']);
+ @ldap_bind($ds, $GLOBALS['conf']['auth']['params']['binddn'], $GLOBALS['conf']['auth']['params']['password']);
+ $searchResults = @ldap_search($ds, 'dc=example,dc=com', 'cn=NextFreeUnixId');
+ $information = @ldap_get_entries($ds, $searchResults);
+ ldap_modify($ds, 'cn=NextFreeUnixId,dc=example,dc=com', array('uidnumber' => $information[0]['uidnumber'][0] + 1));
+ @ldap_close($ds);
+ $entry['uidNumber'] = $information[0]['uidnumber'][0];
+ }
// need to check for new users (password) and edited users (user_pass_2)
if (isset($credentials) && isset($credentials['password'])) {
$entry['userPassword'] = '{MD5}' . base64_encode(mHash(MHASH_MD5, $credentials['password']));
More information about the cvs
mailing list