summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 404d37a)
raw | patch | inline | side by side (parent: 404d37a)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 25 May 2007 06:12:25 +0000 (06:12 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 25 May 2007 06:12:25 +0000 (06:12 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@6473 594d385d-05f5-0310-b6e9-bd551577e9d8
setup/class_setupStep_Migrate.inc | patch | blob | history |
index 0852d27b1af75cf0e65bcf25fd6a14f6277a1c52..182ea7e18c4f8143949610b66dd084809910ea29 100644 (file)
$group_ou = $cv['groupou'];
$ldap->cd($cv['base']);
+
+ /***********
+ * Get all gosaDepartments to be able to
+ * validate correct ldap tree position of every single user
+ ***********/
+ $valid_deps = array();
+ $valid_deps['/'] = $cv['base'];
+ $ldap->search("(&(objectClass=gosaDepartment)(ou=*))",array("dn","ou"));
+ while($attrs = $ldap->fetch()){
+ $valid_deps[$attrs['ou'][0]] = $attrs['dn'];
+ }
+
+ /***********
+ * Get all groups
+ ***********/
$res = $ldap->search("(objectClass=posixGroup)",array("dn"));
if(!$res){
$this->checks['outside_groups']['STATUS'] = FALSE;
return(false);
}
-
- $this->outside_groups = array();
while($attrs = $ldap->fetch()){
- if((!preg_match("/^[^,]+,".normalizePreg($group_ou)."/",$attrs['dn'])) && !preg_match("/,dc=addressbook,/",$attrs['dn'])){
+ $group_db_base = preg_replace("/^[^,]+,".normalizePreg($group_ou)."/","",$attrs['dn']);
+
+ /* Check if entry is not an addressbook only user
+ * and verify that he is in a valid department
+ */
+ if( !preg_match("/".normalizePreg("dc=addressbook,")."/",$group_db_base) &&
+ !in_array($group_db_base,$valid_deps)
+ ){
$attrs['selected'] = FALSE;
$attrs['ldif'] = "";
- $this->outside_groups[base64_encode($attrs['dn'])] = $attrs;
+ $this->outside_users[base64_encode($attrs['dn'])] = $attrs;
}
}
$cv['tls']);
/* Skip GOsa internal departments */
- $skip_dns = array("/^ou=people,/","/^ou=groups,/","/(,|)ou=configs,/","/(,|)ou=systems,/",
+ $skip_dns = array("/".$cv['peopleou']."/","/".$cv['groupou']."/","/^ou=people,/",
+ "/^ou=groups,/","/(,|)ou=configs,/","/(,|)ou=systems,/",
"/^ou=apps,/","/^ou=mime,/","/^ou=aclroles,/","/^ou=incoming,/",
"/ou=snapshots,/","/(,|)dc=addressbook,/","/^(,|)ou=machineaccounts,/",
"/(,|)ou=winstations,/");
-
/* Get all invisible departments */
$ldap->cd($cv['base']);
$res = $ldap->search("(&(objectClass=organizationalUnit)(!(objectClass=gosaDepartment)))",array("ou","description","dn"));
$this->acl_create_changes.= $this->array_to_ldif($new_group_attrs);
}else{
$ldap->cd($cv['base']);
- $ldap->create_missing_trees($cv['groupou'].",".$cv['base']);
+ $ldap->create_missing_trees($group_ou.$cv['base']);
$ldap->cd($new_group_dn);
$res = $ldap->add($new_group_attrs);
if(!$res){
{
/* Get collected configuration settings */
$cv = $this->parent->captured_values;
+ $people_ou = trim($cv['peopleou']);
/* Establish ldap connection */
$ldap = new LDAP($cv['admin'],
FALSE,
$cv['tls']);
- $ldap->cd($cv['base']);
- $ldap->search("(".$cv['peopleou'].")",array("dn"));
-
- if($ldap->count() == 0 ){
- $add_dn = $cv['peopleou'].",".$cv['base'];
- $naming_attr = preg_replace("/=.*$/","",$add_dn);
- $naming_value = preg_replace("/^[^=]*+=([^,]*).*$/","\\1",$add_dn);
- $add = array();
- $add['objectClass'] = array("organizationalUnit");
- $add[$naming_attr] = $naming_value;
+
+ /*****************
+ * If people ou is NOT empty
+ * search for for all objects matching the given container
+ *****************/
+ if(!empty($people_ou)){
+ $ldap->search("(".$people_ou.")",array("dn"));
+
+ /* Create people ou if there is currently none */
+ if($ldap->count() == 0 ){
+ $add_dn = $cv['peopleou'].",".$cv['base'];
+ $naming_attr = preg_replace("/=.*$/","",$add_dn);
+ $naming_value = preg_replace("/^[^=]*+=([^,]*).*$/","\\1",$add_dn);
+ $add = array();
+ $add['objectClass'] = array("organizationalUnit");
+ $add[$naming_attr] = $naming_value;
+ $ldap->cd($cv['base']);
+ $ldap->create_missing_trees(preg_replace("/^[^,]+,/","",$add_dn));
+ $ldap->cd($add_dn);
+ $ldap->add($add);
+ }
- $ldap->cd($cv['base']);
- $ldap->create_missing_trees(preg_replace("/^[^,]+,/","",$add_dn));
- $ldap->cd($add_dn);
- $ldap->add($add);
- }
+ /* Create result */
+ $ldap->search("(".$cv['peopleou'].")",array("dn"));
+ $tmp = array();
+ while($attrs= $ldap->fetch()){
+ if(!preg_match("/ou=snapshots,/",$attrs['dn'])){
+ $tmp[base64_encode($attrs['dn'])] = $ldap->fix($attrs['dn']);
+ }
+ }
+ } else{
- $ldap->search("(".$cv['peopleou'].")",array("dn"));
- $tmp = array();
- while($attrs= $ldap->fetch()){
- if(!preg_match("/ou=snapshots,/",$attrs['dn'])){
- $tmp[base64_encode($attrs['dn'])] = $ldap->fix($attrs['dn']);
+ /************
+ * If people ou is empty
+ * Get all valid gosaDepartments
+ ************/
+ $ldap->cd($cv['base']);
+ $tmp = array();
+ $ldap->search("(&(objectClass=gosaDepartment)(ou=*))",array("dn"));
+ $tmp['/'] = $cv['base'];
+ while($attrs = $ldap->fetch()){
+ $tmp[base64_encode($attrs['dn'])] = $ldap->fix($attrs['dn']);;
}
}
return($tmp);
}
+
function get_all_winstation_ous()
{
/* Get collected configuration settings */
$cv['connection'],
FALSE,
$cv['tls']);
+
+ $group_ou = trim($cv['groupou']);
+ if(!empty($group_ou)){
+ $group_ou = trim($group_ou);
+ }
+ /************
+ * If group ou is NOT empty
+ * Get all valid group ous, create one if necessary
+ ************/
$ldap->cd($cv['base']);
- $ldap->search("(".$cv['groupou'].")",array("dn"));
-
- if($ldap->count() == 0 ){
- $add_dn = $cv['groupou'].",".$cv['base'];
- $naming_attr = preg_replace("/=.*$/","",$add_dn);
- $naming_value = preg_replace("/^[^=]*+=([^,]*).*$/","\\1",$add_dn);
- $add = array();
- $add['objectClass'] = array("organizationalUnit");
- $add[$naming_attr] = $naming_value;
+ if(!empty($group_ou)){
+ $ldap->search("(".$group_ou.")",array("dn"));
+ if($ldap->count() == 0 ){
+ $add_dn = $group_ou.$cv['base'];
+ $naming_attr = preg_replace("/=.*$/","",$add_dn);
+ $naming_value = preg_replace("/^[^=]*+=([^,]*).*$/","\\1",$add_dn);
+ $add = array();
+ $add['objectClass'] = array("organizationalUnit");
+ $add[$naming_attr] = $naming_value;
+ $ldap->cd($cv['base']);
+ $ldap->create_missing_trees(preg_replace("/^[^,]+,/","",$add_dn));
+ $ldap->cd($add_dn);
+ $ldap->add($add);
+ }
+ $ldap->search("(".$group_ou.")",array("dn"));
+ $tmp = array();
+ while($attrs= $ldap->fetch()){
+ if(!preg_match("/ou=snapshots,/",$attrs['dn'])){
+ $tmp[base64_encode($attrs['dn'])] = $ldap->fix($attrs['dn']);
+ }
+ }
+ }else{
+ /************
+ * If group ou is empty
+ * Get all valid gosaDepartments
+ ************/
$ldap->cd($cv['base']);
- $ldap->create_missing_trees(preg_replace("/^[^,]+,/","",$add_dn));
- $ldap->cd($add_dn);
- $ldap->add($add);
- }
-
- $ldap->search("(".$cv['groupou'].")",array("dn"));
- $tmp = array();
- while($attrs= $ldap->fetch()){
- if(!preg_match("/ou=snapshots,/",$attrs['dn'])){
- $tmp[base64_encode($attrs['dn'])] = $ldap->fix($attrs['dn']);
+ $tmp = array();
+ $ldap->search("(&(objectClass=gosaDepartment)(ou=*))",array("dn"));
+ $tmp['/'] = $cv['base'];
+ while($attrs = $ldap->fetch()){
+ $tmp[base64_encode($attrs['dn'])] = $ldap->fix($attrs['dn']);;
}
}
return($tmp);