[SCM] Samba Shared Repository - branch v3-2-test updated - release-3-2-0pre2-530-gc0be84c

Günther Deschner gd at samba.org
Fri Mar 28 15:44:48 GMT 2008


The branch, v3-2-test has been updated
       via  c0be84c96d8133c6b77d1f0efe41f5f2373febb3 (commit)
       via  380e9d26db5341d10807ccbfb413d0f53d3ffc71 (commit)
      from  16b5800d4e3a8b88bac67b2550d14e0aaaa302a9 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-test


- Log -----------------------------------------------------------------
commit c0be84c96d8133c6b77d1f0efe41f5f2373febb3
Author: Günther Deschner <gd at samba.org>
Date:   Fri Mar 28 16:39:02 2008 +0100

    Support "net ads join" format while joining to a specific ou.
    
    libnetjoin now supports Computers/Servers/Unix as well as
    ou=Computers,ou=Servers,ou=Unix,dc=ber,dc=realm,dc=com.
    
    Guenther

commit 380e9d26db5341d10807ccbfb413d0f53d3ffc71
Author: Günther Deschner <gd at samba.org>
Date:   Fri Mar 28 16:33:54 2008 +0100

    Add ads_check_ou_dn().
    
    Guenther

-----------------------------------------------------------------------

Summary of changes:
 source/libads/ldap.c        |   47 +++++++++++++++++++++++++++++++++++++++++++
 source/libnet/libnet_join.c |    5 ++++
 2 files changed, 52 insertions(+), 0 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/libads/ldap.c b/source/libads/ldap.c
index 00d36b7..a9eff48 100644
--- a/source/libads/ldap.c
+++ b/source/libads/ldap.c
@@ -22,6 +22,7 @@
 */
 
 #include "includes.h"
+#include "lib/ldb/include/includes.h"
 
 #ifdef HAVE_LDAP
 
@@ -3551,4 +3552,50 @@ const char *ads_get_extended_right_name_by_guid(ADS_STRUCT *ads,
 	
 }
 
+/**
+ * verify or build and verify an account ou
+ * @param mem_ctx Pointer to talloc context
+ * @param ads connection to ads server
+ * @param account_ou
+ * @return status of search
+ **/
+
+ADS_STATUS ads_check_ou_dn(TALLOC_CTX *mem_ctx,
+			   ADS_STRUCT *ads,
+			   const char *account_ou)
+{
+	struct ldb_dn *name_dn = NULL;
+	const char *name = NULL;
+	char *ou_string = NULL;
+
+	name_dn = ldb_dn_explode(mem_ctx, account_ou);
+	if (name_dn) {
+		return ADS_SUCCESS;
+	}
+
+	ou_string = ads_ou_string(ads, account_ou);
+	if (!ou_string) {
+		return ADS_ERROR_LDAP(LDAP_INVALID_DN_SYNTAX);
+	}
+
+	name = talloc_asprintf(mem_ctx, "%s,%s", ou_string,
+			       ads->config.bind_path);
+	SAFE_FREE(ou_string);
+	if (!name) {
+		return ADS_ERROR_LDAP(LDAP_NO_MEMORY);
+	}
+
+	name_dn = ldb_dn_explode(mem_ctx, name);
+	if (!name_dn) {
+		return ADS_ERROR_LDAP(LDAP_INVALID_DN_SYNTAX);
+	}
+
+	account_ou = talloc_strdup(mem_ctx, name);
+	if (!account_ou) {
+		return ADS_ERROR_LDAP(LDAP_NO_MEMORY);
+	}
+
+	return ADS_SUCCESS;
+}
+
 #endif
diff --git a/source/libnet/libnet_join.c b/source/libnet/libnet_join.c
index f55d558..90e1b59 100644
--- a/source/libnet/libnet_join.c
+++ b/source/libnet/libnet_join.c
@@ -207,6 +207,11 @@ static ADS_STATUS libnet_join_precreate_machine_acct(TALLOC_CTX *mem_ctx,
 	const char *attrs[] = { "dn", NULL };
 	bool moved = false;
 
+	status = ads_check_ou_dn(mem_ctx, r->in.ads, r->in.account_ou);
+	if (!ADS_ERR_OK(status)) {
+		return status;
+	}
+
 	status = ads_search_dn(r->in.ads, &res, r->in.account_ou, attrs);
 	if (!ADS_ERR_OK(status)) {
 		return status;


-- 
Samba Shared Repository


More information about the samba-cvs mailing list