svn commit: samba r15633 - branches/SAMBA_3_0/source/lib branches/SAMBA_3_0/source/passdb trunk/source/lib trunk/source/passdb

gd at samba.org gd at samba.org
Tue May 16 13:26:51 GMT 2006


Author: gd
Date: 2006-05-16 13:26:49 +0000 (Tue, 16 May 2006)
New Revision: 15633

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

Log:
Minor smbldap/pdb_ldap cleanup

Guenther

Modified:
   branches/SAMBA_3_0/source/lib/smbldap.c
   branches/SAMBA_3_0/source/passdb/pdb_ldap.c
   trunk/source/lib/smbldap.c
   trunk/source/passdb/pdb_ldap.c


Changeset:
Modified: branches/SAMBA_3_0/source/lib/smbldap.c
===================================================================
--- branches/SAMBA_3_0/source/lib/smbldap.c	2006-05-16 11:23:29 UTC (rev 15632)
+++ branches/SAMBA_3_0/source/lib/smbldap.c	2006-05-16 13:26:49 UTC (rev 15633)
@@ -981,7 +981,7 @@
 
 	ldap_get_option(ldap_state->ldap_struct, LDAP_OPT_PROTOCOL_VERSION, &version);
 
-	if (smbldap_has_control(ldap_state, ADS_PAGE_CTL_OID) && version == 3) {
+	if (smbldap_has_control(ldap_state->ldap_struct, ADS_PAGE_CTL_OID) && version == 3) {
 		ldap_state->paged_results = True;
 	}
 
@@ -1554,7 +1554,6 @@
 /*******************************************************************
  Return a copy of the DN for a LDAPMessage. Convert from utf8 to CH_UNIX.
 ********************************************************************/
-
 char *smbldap_get_dn(LDAP *ld, LDAPMessage *entry)
 {
 	char *utf8_dn, *unix_dn;
@@ -1595,7 +1594,7 @@
  Check if root-dse has a certain Control or Extension
 ********************************************************************/
 
-static BOOL smbldap_check_root_dse(struct smbldap_state *ldap_state, const char **attrs, const char *value) 
+static BOOL smbldap_check_root_dse(LDAP *ld, const char **attrs, const char *value) 
 {
 	LDAPMessage *msg = NULL;
 	LDAPMessage *entry = NULL;
@@ -1615,7 +1614,7 @@
 		return False;
 	}
 
-	rc = ldap_search_s(ldap_state->ldap_struct, "", LDAP_SCOPE_BASE, 
+	rc = ldap_search_s(ld, "", LDAP_SCOPE_BASE, 
 			   "(objectclass=*)", CONST_DISCARD(char **, attrs), 0 , &msg);
 
 	if (rc != LDAP_SUCCESS) {
@@ -1623,21 +1622,21 @@
 		return False;
 	}
 
-	num_result = ldap_count_entries(ldap_state->ldap_struct, msg);
+	num_result = ldap_count_entries(ld, msg);
 
 	if (num_result != 1) {
 		DEBUG(3,("smbldap_check_root_dse: Expected one rootDSE, got %d\n", num_result));
 		goto done;
 	}
 
-	entry = ldap_first_entry(ldap_state->ldap_struct, msg);
+	entry = ldap_first_entry(ld, msg);
 
 	if (entry == NULL) {
 		DEBUG(3,("smbldap_check_root_dse: Could not retrieve rootDSE\n"));
 		goto done;
 	}
 
-	values = ldap_get_values(ldap_state->ldap_struct, entry, attrs[0]);
+	values = ldap_get_values(ld, entry, attrs[0]);
 
 	if (values == NULL) {
 		DEBUG(5,("smbldap_check_root_dse: LDAP Server does not support any %s\n", attrs[0]));
@@ -1671,28 +1670,28 @@
  Check if LDAP-Server supports a certain Control (OID in string format)
 ********************************************************************/
 
-BOOL smbldap_has_control(struct smbldap_state *ldap_state, const char *control)
+BOOL smbldap_has_control(LDAP *ld, const char *control)
 {
 	const char *attrs[] = { "supportedControl", NULL };
-	return smbldap_check_root_dse(ldap_state, attrs, control);
+	return smbldap_check_root_dse(ld, attrs, control);
 }
 
 /*******************************************************************
  Check if LDAP-Server supports a certain Extension (OID in string format)
 ********************************************************************/
 
-BOOL smbldap_has_extension(struct smbldap_state *ldap_state, const char *extension)
+BOOL smbldap_has_extension(LDAP *ld, const char *extension)
 {
 	const char *attrs[] = { "supportedExtension", NULL };
-	return smbldap_check_root_dse(ldap_state, attrs, extension);
+	return smbldap_check_root_dse(ld, attrs, extension);
 }
 
 /*******************************************************************
  Check if LDAP-Server holds a given namingContext
 ********************************************************************/
 
-BOOL smbldap_has_naming_context(struct smbldap_state *ldap_state, const char *naming_context)
+BOOL smbldap_has_naming_context(LDAP *ld, const char *naming_context)
 {
 	const char *attrs[] = { "namingContexts", NULL };
-	return smbldap_check_root_dse(ldap_state, attrs, naming_context);
+	return smbldap_check_root_dse(ld, attrs, naming_context);
 }

Modified: branches/SAMBA_3_0/source/passdb/pdb_ldap.c
===================================================================
--- branches/SAMBA_3_0/source/passdb/pdb_ldap.c	2006-05-16 11:23:29 UTC (rev 15632)
+++ branches/SAMBA_3_0/source/passdb/pdb_ldap.c	2006-05-16 13:26:49 UTC (rev 15633)
@@ -212,7 +212,7 @@
 		return ntstatus;
 	}
 
-	if (!smbldap_has_naming_context(ldap_state->smbldap_state, lp_ldap_suffix())) {
+	if (!smbldap_has_naming_context(ldap_state->smbldap_state->ldap_struct, lp_ldap_suffix())) {
 		DEBUG(3,("ldapsam_get_seq_num: DIT not configured to hold %s "
 			 "as top-level namingContext\n", lp_ldap_suffix()));
 		return ntstatus;
@@ -1505,11 +1505,6 @@
 	return NT_STATUS_OK;
 }	
 
-static BOOL ldapsam_can_pwchange_exop(struct smbldap_state *ldap_state)
-{
-	return smbldap_has_extension(ldap_state, LDAP_EXOP_MODIFY_PASSWD);
-}
-
 /********************************************************************
  Do the actual modification - also change a plaintext passord if 
  it it set.
@@ -1572,7 +1567,9 @@
 		char *utf8_dn;
 
 		if (!ldap_state->is_nds_ldap) {
-			if (!ldapsam_can_pwchange_exop(ldap_state->smbldap_state)) {
+
+			if (!smbldap_has_extension(ldap_state->smbldap_state->ldap_struct, 
+						   LDAP_EXOP_MODIFY_PASSWD)) {
 				DEBUG(2, ("ldap password change requested, but LDAP "
 					  "server does not support it -- ignoring\n"));
 				return NT_STATUS_OK;

Modified: trunk/source/lib/smbldap.c
===================================================================
--- trunk/source/lib/smbldap.c	2006-05-16 11:23:29 UTC (rev 15632)
+++ trunk/source/lib/smbldap.c	2006-05-16 13:26:49 UTC (rev 15633)
@@ -981,7 +981,7 @@
 
 	ldap_get_option(ldap_state->ldap_struct, LDAP_OPT_PROTOCOL_VERSION, &version);
 
-	if (smbldap_has_control(ldap_state, ADS_PAGE_CTL_OID) && version == 3) {
+	if (smbldap_has_control(ldap_state->ldap_struct, ADS_PAGE_CTL_OID) && version == 3) {
 		ldap_state->paged_results = True;
 	}
 
@@ -1554,7 +1554,6 @@
 /*******************************************************************
  Return a copy of the DN for a LDAPMessage. Convert from utf8 to CH_UNIX.
 ********************************************************************/
-
 char *smbldap_get_dn(LDAP *ld, LDAPMessage *entry)
 {
 	char *utf8_dn, *unix_dn;
@@ -1595,7 +1594,7 @@
  Check if root-dse has a certain Control or Extension
 ********************************************************************/
 
-static BOOL smbldap_check_root_dse(struct smbldap_state *ldap_state, const char **attrs, const char *value) 
+static BOOL smbldap_check_root_dse(LDAP *ld, const char **attrs, const char *value) 
 {
 	LDAPMessage *msg = NULL;
 	LDAPMessage *entry = NULL;
@@ -1615,7 +1614,7 @@
 		return False;
 	}
 
-	rc = ldap_search_s(ldap_state->ldap_struct, "", LDAP_SCOPE_BASE, 
+	rc = ldap_search_s(ld, "", LDAP_SCOPE_BASE, 
 			   "(objectclass=*)", CONST_DISCARD(char **, attrs), 0 , &msg);
 
 	if (rc != LDAP_SUCCESS) {
@@ -1623,21 +1622,21 @@
 		return False;
 	}
 
-	num_result = ldap_count_entries(ldap_state->ldap_struct, msg);
+	num_result = ldap_count_entries(ld, msg);
 
 	if (num_result != 1) {
 		DEBUG(3,("smbldap_check_root_dse: Expected one rootDSE, got %d\n", num_result));
 		goto done;
 	}
 
-	entry = ldap_first_entry(ldap_state->ldap_struct, msg);
+	entry = ldap_first_entry(ld, msg);
 
 	if (entry == NULL) {
 		DEBUG(3,("smbldap_check_root_dse: Could not retrieve rootDSE\n"));
 		goto done;
 	}
 
-	values = ldap_get_values(ldap_state->ldap_struct, entry, attrs[0]);
+	values = ldap_get_values(ld, entry, attrs[0]);
 
 	if (values == NULL) {
 		DEBUG(5,("smbldap_check_root_dse: LDAP Server does not support any %s\n", attrs[0]));
@@ -1671,28 +1670,28 @@
  Check if LDAP-Server supports a certain Control (OID in string format)
 ********************************************************************/
 
-BOOL smbldap_has_control(struct smbldap_state *ldap_state, const char *control)
+BOOL smbldap_has_control(LDAP *ld, const char *control)
 {
 	const char *attrs[] = { "supportedControl", NULL };
-	return smbldap_check_root_dse(ldap_state, attrs, control);
+	return smbldap_check_root_dse(ld, attrs, control);
 }
 
 /*******************************************************************
  Check if LDAP-Server supports a certain Extension (OID in string format)
 ********************************************************************/
 
-BOOL smbldap_has_extension(struct smbldap_state *ldap_state, const char *extension)
+BOOL smbldap_has_extension(LDAP *ld, const char *extension)
 {
 	const char *attrs[] = { "supportedExtension", NULL };
-	return smbldap_check_root_dse(ldap_state, attrs, extension);
+	return smbldap_check_root_dse(ld, attrs, extension);
 }
 
 /*******************************************************************
  Check if LDAP-Server holds a given namingContext
 ********************************************************************/
 
-BOOL smbldap_has_naming_context(struct smbldap_state *ldap_state, const char *naming_context)
+BOOL smbldap_has_naming_context(LDAP *ld, const char *naming_context)
 {
 	const char *attrs[] = { "namingContexts", NULL };
-	return smbldap_check_root_dse(ldap_state, attrs, naming_context);
+	return smbldap_check_root_dse(ld, attrs, naming_context);
 }

Modified: trunk/source/passdb/pdb_ldap.c
===================================================================
--- trunk/source/passdb/pdb_ldap.c	2006-05-16 11:23:29 UTC (rev 15632)
+++ trunk/source/passdb/pdb_ldap.c	2006-05-16 13:26:49 UTC (rev 15633)
@@ -212,7 +212,7 @@
 		return ntstatus;
 	}
 
-	if (!smbldap_has_naming_context(ldap_state->smbldap_state, lp_ldap_suffix())) {
+	if (!smbldap_has_naming_context(ldap_state->smbldap_state->ldap_struct, lp_ldap_suffix())) {
 		DEBUG(3,("ldapsam_get_seq_num: DIT not configured to hold %s "
 			 "as top-level namingContext\n", lp_ldap_suffix()));
 		return ntstatus;
@@ -1505,11 +1505,6 @@
 	return NT_STATUS_OK;
 }	
 
-static BOOL ldapsam_can_pwchange_exop(struct smbldap_state *ldap_state)
-{
-	return smbldap_has_extension(ldap_state, LDAP_EXOP_MODIFY_PASSWD);
-}
-
 /********************************************************************
  Do the actual modification - also change a plaintext passord if 
  it it set.
@@ -1572,7 +1567,9 @@
 		char *utf8_dn;
 
 		if (!ldap_state->is_nds_ldap) {
-			if (!ldapsam_can_pwchange_exop(ldap_state->smbldap_state)) {
+
+			if (!smbldap_has_extension(ldap_state->smbldap_state->ldap_struct, 
+						   LDAP_EXOP_MODIFY_PASSWD)) {
 				DEBUG(2, ("ldap password change requested, but LDAP "
 					  "server does not support it -- ignoring\n"));
 				return NT_STATUS_OK;



More information about the samba-cvs mailing list