s3:groupdb: allocate a gid after allocating a rid in pdb_default_create_alias()
[kai/samba.git] / source3 / groupdb / mapping.c
index 4cfe9957f4dcd98eeffa26c52acd0c47c773d378..5e2e54487e5dfbd79edd1a7af9c31c515a2049c7 100644 (file)
@@ -486,21 +486,22 @@ NTSTATUS pdb_default_create_alias(struct pdb_methods *methods,
                return NT_STATUS_ALIAS_EXISTS;
        }
 
-       if (!winbind_allocate_gid(&gid)) {
-               DEBUG(3, ("Could not get a gid out of winbind\n"));
+       if (!pdb_new_rid(&new_rid)) {
+               DEBUG(0, ("Could not allocate a RID.\n"));
                return NT_STATUS_ACCESS_DENIED;
        }
 
-       if (!pdb_new_rid(&new_rid)) {
-               DEBUG(0, ("Could not allocate a RID -- wasted a gid :-(\n"));
+       sid_compose(&sid, get_global_sam_sid(), new_rid);
+
+       if (!winbind_allocate_gid(&gid)) {
+               DEBUG(3, ("Could not get a gid out of winbind - "
+                         "wasted a rid :-(\n"));
                return NT_STATUS_ACCESS_DENIED;
        }
 
        DEBUG(10, ("Creating alias %s with gid %u and rid %u\n",
                   name, (unsigned int)gid, (unsigned int)new_rid));
 
-       sid_compose(&sid, get_global_sam_sid(), new_rid);
-
        map.gid = gid;
        sid_copy(&map.sid, &sid);
        map.sid_name_use = SID_NAME_ALIAS;