Author: jerry
Date: 2005-12-12 18:55:54 +0000 (Mon, 12 Dec 2005)
New Revision: 12196

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=12196

Log:
patch from Krishna Ganugapati <[EMAIL PROTECTED]>

Use the subtree delete ldap control when running 'net ads leave'
to ensure that the machine account is actually deleted.


Modified:
   branches/SAMBA_3_0/source/libads/ldap.c
   trunk/source/libads/ldap.c


Changeset:
Modified: branches/SAMBA_3_0/source/libads/ldap.c
===================================================================
--- branches/SAMBA_3_0/source/libads/ldap.c     2005-12-12 18:22:02 UTC (rev 
12195)
+++ branches/SAMBA_3_0/source/libads/ldap.c     2005-12-12 18:55:54 UTC (rev 
12196)
@@ -37,6 +37,9 @@
  * codepoints in UTF-8).  This may have to change at some point
  **/
 
+
+#define LDAP_SERVER_TREE_DELETE_OID    "1.2.840.113556.1.4.805"
+
 static SIG_ATOMIC_T gotalarm;
                                                                                
                                    
 /***************************************************************
@@ -1796,7 +1799,12 @@
        void *res, *msg;
        char *hostnameDN, *host; 
        int rc;
+       LDAPControl ldap_control;
+       LDAPControl  * pldap_control[] = {&ldap_control, 0};
 
+       memset(&ldap_control, 0, sizeof(LDAPControl));
+       ldap_control.ldctl_oid = (char *)LDAP_SERVER_TREE_DELETE_OID;
+
        /* hostname must be lowercase */
        host = SMB_STRDUP(hostname);
        strlower_m(host);
@@ -1813,7 +1821,15 @@
        }
 
        hostnameDN = ads_get_dn(ads, (LDAPMessage *)msg);
-       rc = ldap_delete_s(ads->ld, hostnameDN);
+
+
+       rc = ldap_delete_ext_s(ads->ld, hostnameDN, pldap_control, NULL);
+       if (rc) {
+               DEBUG(3,("ldap_delete_ext_s failed with error code %d\n", rc));
+       }else {
+               DEBUG(3,("ldap_delete_ext_s succeeded with error code %d\n", 
rc));
+       }
+
        ads_memfree(ads, hostnameDN);
        if (rc != LDAP_SUCCESS) {
                return ADS_ERROR(rc);

Modified: trunk/source/libads/ldap.c
===================================================================
--- trunk/source/libads/ldap.c  2005-12-12 18:22:02 UTC (rev 12195)
+++ trunk/source/libads/ldap.c  2005-12-12 18:55:54 UTC (rev 12196)
@@ -37,6 +37,9 @@
  * codepoints in UTF-8).  This may have to change at some point
  **/
 
+
+#define LDAP_SERVER_TREE_DELETE_OID    "1.2.840.113556.1.4.805"
+
 static SIG_ATOMIC_T gotalarm;
                                                                                
                                    
 /***************************************************************
@@ -1796,7 +1799,12 @@
        void *res, *msg;
        char *hostnameDN, *host; 
        int rc;
+       LDAPControl ldap_control;
+       LDAPControl  * pldap_control[] = {&ldap_control, 0};
 
+       memset(&ldap_control, 0, sizeof(LDAPControl));
+       ldap_control.ldctl_oid = (char *)LDAP_SERVER_TREE_DELETE_OID;
+
        /* hostname must be lowercase */
        host = SMB_STRDUP(hostname);
        strlower_m(host);
@@ -1813,7 +1821,15 @@
        }
 
        hostnameDN = ads_get_dn(ads, (LDAPMessage *)msg);
-       rc = ldap_delete_s(ads->ld, hostnameDN);
+
+
+       rc = ldap_delete_ext_s(ads->ld, hostnameDN, pldap_control, NULL);
+       if (rc) {
+               DEBUG(3,("ldap_delete_ext_s failed with error code %d\n", rc));
+       }else {
+               DEBUG(3,("ldap_delete_ext_s succeeded with error code %d\n", 
rc));
+       }
+
        ads_memfree(ads, hostnameDN);
        if (rc != LDAP_SUCCESS) {
                return ADS_ERROR(rc);

Reply via email to