svn commit: samba r13716 - in trunk/source/passdb: .

idra at samba.org idra at samba.org
Mon Feb 27 15:25:52 GMT 2006


Author: idra
Date: 2006-02-27 15:25:51 +0000 (Mon, 27 Feb 2006)
New Revision: 13716

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

Log:

Use smbldap_make_mod as Volker suggested


Modified:
   trunk/source/passdb/pdb_ldap.c


Changeset:
Modified: trunk/source/passdb/pdb_ldap.c
===================================================================
--- trunk/source/passdb/pdb_ldap.c	2006-02-27 14:45:27 UTC (rev 13715)
+++ trunk/source/passdb/pdb_ldap.c	2006-02-27 15:25:51 UTC (rev 13716)
@@ -5223,7 +5223,6 @@
 	LDAPMod **mods = NULL;
 	char *filter;
 	char *gidstr;
-	char *newgidstr;
 	const char *dn = NULL;
 	gid_t gid;
 	int rc;
@@ -5234,8 +5233,8 @@
 		DEBUG(0,("ldapsam_set_primary_group: failed to retieve gid from user's group SID!\n"));
 		return NT_STATUS_UNSUCCESSFUL;
 	}
-	newgidstr = talloc_asprintf(mem_ctx, "%d", gid);
-	if (!newgidstr) {
+	gidstr = talloc_asprintf(mem_ctx, "%d", gid);
+	if (!gidstr) {
 		DEBUG(0,("ldapsam_set_primary_group: Out of Memory!\n"));
 		return NT_STATUS_NO_MEMORY;
 	}
@@ -5277,22 +5276,14 @@
 		return NT_STATUS_NO_MEMORY;
 	}
 
-	/* retrieve the current gid */
-	gidstr = smbldap_talloc_single_attribute(priv2ld(ldap_state), entry, "gidNumber", mem_ctx);
-	if (!gidstr) {
-		DEBUG (0, ("ldapsam_set_primary_group: Unable to find the user's gid!\n"));
-		return NT_STATUS_INTERNAL_DB_CORRUPTION;
-	}
-
 	/* remove the old one, and add the new one, this way we do not risk races */
-	smbldap_set_mod(&mods, LDAP_MOD_DELETE, "gidNumber", gidstr);
-	smbldap_set_mod(&mods, LDAP_MOD_ADD, "gidNumber", newgidstr);
+	smbldap_make_mod(priv2ld(ldap_state), entry, &mods, "gidNumber", gidstr);
 
 	rc = smbldap_modify(ldap_state->smbldap_state, dn, mods);
 
 	if (rc != LDAP_SUCCESS) {
-		DEBUG(0,("ldapsam_set_primary_group: failed to modify [%s] primary group [%s] -> [%s]\n",
-			 pdb_get_username(sampass), gidstr, newgidstr));
+		DEBUG(0,("ldapsam_set_primary_group: failed to modify [%s] primary group to [%s]\n",
+			 pdb_get_username(sampass), gidstr));
 		return NT_STATUS_UNSUCCESSFUL;
 	}
 



More information about the samba-cvs mailing list