[2038] in Moira Commits

home help back first fref pref prev next nref lref last post

/svn/moira r4180 - trunk/moira/incremental/ldap

daemon@ATHENA.MIT.EDU (Garry Zacheiss)
Tue Sep 9 20:36:45 2014

Date: Tue, 9 Sep 2014 20:36:38 -0400
From: Garry Zacheiss <zacheiss@mit.edu>
Message-Id: <201409100036.s8A0acH7010576@drugstore.mit.edu>
To: moira-commits@mit.edu
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Author: zacheiss
Date: 2014-09-09 20:36:38 -0400 (Tue, 09 Sep 2014)
New Revision: 4180

Modified:
   trunk/moira/incremental/ldap/winad.c
Log:
Don't move machines to orphans container.

Modified: trunk/moira/incremental/ldap/winad.c
===================================================================
--- trunk/moira/incremental/ldap/winad.c	2014-09-09 14:50:45 UTC (rev 4179)
+++ trunk/moira/incremental/ldap/winad.c	2014-09-10 00:36:38 UTC (rev 4180)
@@ -426,8 +426,6 @@
 char  group_ou_security[1024];
 char  group_ou_neither[1024];
 char  group_ou_both[1024]; 
-char  orphans_machines_ou[] = "OU=Machines,OU=Orphans";
-char  orphans_other_ou[] = "OU=Other,OU=Orphans";
 char  security_template_ou[] = "OU=security_templates";
 char *whoami;
 char ldap_domain[256];
@@ -504,7 +502,6 @@
 
 void container_get_dn(char *src, char *dest);
 void container_get_name(char *src, char *dest);
-int container_move_objects(LDAP *ldap_handle, char *dn_path, char *dName);
 int container_rename(LDAP *ldap_handle, char *dn_path, int beforec, 
 		     char **before, int afterc, char **after);
 
@@ -951,11 +948,9 @@
 
   if (strlen(MoiraContainerName) == 0)
     {
-      com_err(whoami, 0, "Unable to fine machine %s (alias %s) container "
-	      "in Moira - moving to orphans OU.",
+      com_err(whoami, 0, "Unable to find machine %s (alias %s) container "
+	      "in Moira - skipping.",
 	      OriginalMachineName, MachineName);
-      machine_move_to_ou(ldap_handle, dn_path, MachineName, 
-			 orphans_machines_ou);
       moira_disconnect();
       return;
     }
@@ -9175,11 +9170,8 @@
 
   if ((rc = ldap_delete_s(ldap_handle, distinguishedName)) != LDAP_SUCCESS)
     {
-      if (rc == LDAP_NOT_ALLOWED_ON_NONLEAF)
-        container_move_objects(ldap_handle, dn_path, distinguishedName);
-      else
-        com_err(whoami, 0, "Unable to delete container %s from directory : %s",
-                av[CONTAINER_NAME], ldap_err2string(rc));
+      com_err(whoami, 0, "Unable to delete container %s from directory : %s",
+	      av[CONTAINER_NAME], ldap_err2string(rc));
     }
 
   return(rc);
@@ -9605,100 +9597,6 @@
   return(rc);
 }
 
-int container_move_objects(LDAP *ldap_handle, char *dn_path, char *dName)
-{
-  char      *attr_array[3];
-  LK_ENTRY  *group_base;
-  LK_ENTRY  *pPtr;
-  int       group_count;
-  char      filter[512];
-  char      new_cn[128];
-  char      temp[256];
-  int       rc;
-  int       NumberOfEntries = 10;
-  int       i;
-  int       count;
-
-  rc = ldap_set_option(ldap_handle, LDAP_OPT_SIZELIMIT, &NumberOfEntries);
-
-  for (i = 0; i < 3; i++)
-    {
-      memset(filter, '\0', sizeof(filter));
-
-      if (i == 0)
-        {
-          strcpy(filter, "(!(|(objectClass=computer)"
-		 "(objectClass=organizationalUnit)))");
-          attr_array[0] = "cn";
-          attr_array[1] = NULL;
-        }
-      else if (i == 1)
-        {
-          strcpy(filter, "(objectClass=computer)");
-          attr_array[0] = "cn";
-          attr_array[1] = NULL;
-        }
-      else
-        {
-          strcpy(filter, "(objectClass=organizationalUnit)");
-          attr_array[0] = "ou";
-          attr_array[1] = NULL;
-        }
-
-      while (1)
-        {
-          if ((rc = linklist_build(ldap_handle, dName, filter, attr_array, 
-                                   &group_base, &group_count, 
-				   LDAP_SCOPE_SUBTREE)) != LDAP_SUCCESS)
-	    break;
-
-          if (group_count == 0)
-            break;
-
-          pPtr = group_base;
-
-          while(pPtr)
-            {
-              if (!strcasecmp(pPtr->attribute, "cn"))
-                {
-                  sprintf(new_cn, "cn=%s", pPtr->value);
-
-                  if (i == 0)
-                    sprintf(temp, "%s,%s", orphans_other_ou, dn_path);
-
-                  if (i == 1)
-                    sprintf(temp, "%s,%s", orphans_machines_ou, dn_path);
-
-                  count = 1;
-
-                  while (1)
-                    {
-                      rc = ldap_rename_s(ldap_handle, pPtr->dn, new_cn, temp,
-                                         TRUE, NULL, NULL);
-                      if (rc == LDAP_ALREADY_EXISTS)
-                        {
-                          sprintf(new_cn, "cn=%s_%d", pPtr->value, count);
-                          ++count;
-                        }
-                      else
-                        break;
-                    }
-                }
-              else if (!strcasecmp(pPtr->attribute, "ou"))
-		rc = ldap_delete_s(ldap_handle, pPtr->dn);
-	      
-              pPtr = pPtr->next;
-            }
-
-          linklist_free(group_base);
-          group_base = NULL;
-          group_count = 0;
-        }
-    }
-
-  return(0);
-}
-
 int get_machine_ou(LDAP *ldap_handle, char *dn_path, char *member, 
 		   char *machine_ou, char *NewMachineName)
 {


home help back first fref pref prev next nref lref last post