diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=*.so --exclude=.#* --exclude=Makefile --exclude=stamp-h --exclude=configure --exclude=findsmb --exclude=*proto*.h --exclude=build_env.h --exclude=tdbsam2_parse_info.h --exclude=config.* --exclude=bin --exclude=*.configure --exclude=autom4te.cache HEAD/source/passdb/pdb_ldap.c HEAD-ioctl/source/passdb/pdb_ldap.c
--- HEAD/source/passdb/pdb_ldap.c	Fri Mar 21 08:38:58 2003
+++ HEAD-ioctl/source/passdb/pdb_ldap.c	Fri Mar 21 08:41:02 2003
@@ -2051,7 +2051,7 @@ static void free_private_data(void **vp)
 	/* No need to free any further, as it is talloc()ed */
 }
 
-static const char *group_attr[] = {"gid", "ntSid", "ntGroupType",
+static const char *group_attr[] = {"cn", "ntSid", "ntGroupType",
 				   "gidNumber",
 				   "displayName", "description",
 				   NULL };
@@ -2097,7 +2097,7 @@ static BOOL init_group_from_ldap(struct 
 	}
 	DEBUG(2, ("Entry found for group: %s\n", temp));
 
-	map->gid = (uint32)atol(temp);
+	map->gid = (gid_t)atol(temp);
 
 	if (!get_single_attribute(ldap_state->ldap_struct, entry, "ntSid",
 				  temp)) {
@@ -2123,6 +2123,11 @@ static BOOL init_group_from_ldap(struct 
 				  temp)) {
 		DEBUG(3, ("Attribute displayName not found\n"));
 		temp[0] = '\0';
+		if (!get_single_attribute(ldap_state->ldap_struct, entry, "cn",
+					  temp)) {
+			DEBUG(0, ("Attributes displayName and cn not found for gidNumber(%i)\n",map->gid));
+			return False;
+		}
 	}
 	fstrcpy(map->nt_name, temp);
 
@@ -2242,8 +2247,8 @@ static NTSTATUS ldapsam_getgrnam(struct 
 	/* TODO: Escaping of name? */
 
 	snprintf(filter, sizeof(filter)-1,
-		 "(&(objectClass=sambaGroupMapping)(displayName=%s))",
-		 name);
+		 "(&(objectClass=sambaGroupMapping)(|(displayName=%s)(cn=%s))",
+		 name,name);
 
 	return ldapsam_getgroup(methods, filter, map);
 }
