@@ -298,7 +298,7 @@ public function check_csrf_token($token) {
298
298
* @throws UserNotFoundException if the user is not found in LDAP
299
299
*/
300
300
public function get_details_from_ldap () {
301
- global $ config , $ group_dir ;
301
+ global $ config , $ group_dir, $ user_dir ;
302
302
$ attributes = array ();
303
303
$ attributes [] = 'dn ' ;
304
304
$ attributes [] = $ config ['ldap ' ]['user_id ' ];
@@ -324,13 +324,18 @@ public function get_details_from_ldap() {
324
324
} else {
325
325
$ this ->active = 1 ;
326
326
}
327
- $ this ->admin = 0 ;
328
327
$ group_member = $ ldapuser [strtolower ($ config ['ldap ' ]['group_member_value ' ])];
329
328
$ ldapgroups = $ this ->ldap ->search ($ config ['ldap ' ]['dn_group ' ], LDAP ::escape ($ config ['ldap ' ]['group_member ' ]).'= ' .LDAP ::escape ($ group_member ), array ('cn ' ));
330
329
$ memberships = array ();
331
330
foreach ($ ldapgroups as $ ldapgroup ) {
332
331
$ memberships [$ ldapgroup ['cn ' ]] = true ;
333
332
}
333
+ $ this ->admin = isset ($ memberships [$ config ['ldap ' ]['admin_group_cn ' ]]);
334
+ if (isset ($ this ->id )) {
335
+ $ this ->update ();
336
+ } else {
337
+ $ user_dir ->add_user ($ this );
338
+ }
334
339
if (isset ($ config ['ldap ' ]['sync_groups ' ]) && is_array ($ config ['ldap ' ]['sync_groups ' ])) {
335
340
$ syncgroups = $ config ['ldap ' ]['sync_groups ' ];
336
341
} else {
@@ -347,7 +352,6 @@ public function get_details_from_ldap() {
347
352
$ group_dir ->add_group ($ group );
348
353
}
349
354
if (isset ($ memberships [$ syncgroup ])) {
350
- if ($ syncgroup == $ config ['ldap ' ]['admin_group_cn ' ]) $ this ->admin = 1 ;
351
355
if (!$ this ->member_of ($ group )) {
352
356
$ group ->add_member ($ this );
353
357
}
0 commit comments