summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a5f3998)
raw | patch | inline | side by side (parent: a5f3998)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 15 Sep 2009 12:23:05 +0000 (12:23 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 15 Sep 2009 12:23:05 +0000 (12:23 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14251 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-core/include/functions.inc | patch | blob | history |
index d02d7d46264fd15083e23f313b2ee7b1a9a8c636..4962bb11f2eb1dec3bdb7459eadee2bed2de01e2 100644 (file)
/* Recurse through all possible combinations */
$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];
- }
+# /* 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];
+# }
/* Remove used uids and watch out for id tags */
$ret= array();
for ($i= 0, $p= pow(10,$size); $i < $p; $i++){
$number= sprintf("%0".$size."d", $i);
$res= preg_replace('/{id:(\d+)}/', $number, $uid);
- if (!in_array($res, $used)){
+
+ $ldap->search("uid={$res}",array('dn'));
+ if(!count($ldap)){
$uid= $res;
break;
}
mt_srand((double) microtime()*1000000);
$number= sprintf("%0".$size."d", mt_rand(0, pow(10, $size)-1));
$res= preg_replace('/{id#(\d+)}/', $number, $uid);
- if (!in_array($res, $used)){
+ $ldap->search("uid={$res}",array('dn'));
+ if(!count($ldap)){
$uid= $res;
break;
}
}
/* Don't assign used ones */
- if (!in_array($uid, $used)){
+ $ldap->search("uid={$uid}",array('dn'));
+ if(!count($ldap)){
/* Add uid, but remove {} first. These are invalid anyway. */
$ret[]= preg_replace('/[{}]/', '', $uid);
}