From 658dea19bfeb84e85aa0f1e3c7d72f81d0efb167 Mon Sep 17 00:00:00 2001 From: hickert Date: Tue, 15 Sep 2009 12:36:36 +0000 Subject: [PATCH] Updated gen_uids git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14252 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-core/include/functions.inc | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/gosa-core/include/functions.inc b/gosa-core/include/functions.inc index 4962bb11f..cfe1aa99a 100644 --- a/gosa-core/include/functions.inc +++ b/gosa-core/include/functions.inc @@ -1731,14 +1731,8 @@ function gen_uids($rule, $attributes) $proposed= recurse($stripped, $variables); # /* Get list of used ID's */ -# $used= array(); - $ldap= $config->get_ldap_link(); - $ldap->cd($config->current['BASE']); -# $ldap->search('(uid=*)'); -# -# while($attrs= $ldap->fetch()){ -# $used[]= $attrs['uid'][0]; -# } + $ldap= $config->get_ldap_link(); + $ldap->cd($config->current['BASE']); /* Remove used uids and watch out for id tags */ $ret= array(); @@ -1753,7 +1747,7 @@ function gen_uids($rule, $attributes) $res= preg_replace('/{id:(\d+)}/', $number, $uid); $ldap->search("uid={$res}",array('dn')); - if(!count($ldap)){ + if(!$ldap->count()){ $uid= $res; break; } @@ -1768,7 +1762,7 @@ function gen_uids($rule, $attributes) $number= sprintf("%0".$size."d", mt_rand(0, pow(10, $size)-1)); $res= preg_replace('/{id#(\d+)}/', $number, $uid); $ldap->search("uid={$res}",array('dn')); - if(!count($ldap)){ + if(!$ldap->count()){ $uid= $res; break; } @@ -1777,7 +1771,7 @@ function gen_uids($rule, $attributes) /* Don't assign used ones */ $ldap->search("uid={$uid}",array('dn')); - if(!count($ldap)){ + if(!$ldap->count()){ /* Add uid, but remove {} first. These are invalid anyway. */ $ret[]= preg_replace('/[{}]/', '', $uid); } -- 2.30.2