s3:net Find uid before using it
authorSumit Bose <sbose@redhat.com>
Thu, 17 Mar 2011 11:35:35 +0000 (12:35 +0100)
committerGünther Deschner <gd@samba.org>
Thu, 17 Mar 2011 12:57:28 +0000 (13:57 +0100)
Signed-off-by: Günther Deschner <gd@samba.org>
source3/utils/net_sam.c

index 8a9ca8ad1819bb293589d804e57858373a79e806..af8aaa47dfd37ad36fccd98411a2b92e33897de1 100644 (file)
@@ -1781,6 +1781,13 @@ doma_done:
                                    "Admins group not available!\n"));
                        goto done;
                }
+               if (!winbind_allocate_uid(&uid)) {
+                       d_fprintf(stderr,
+                                 _("Unable to allocate a new uid to create "
+                                   "the Administrator user!\n"));
+                       goto done;
+               }
+
                name = talloc_strdup(tc, "Administrator");
                dn = talloc_asprintf(tc, "uid=Administrator,%s", lp_ldap_user_suffix());
                uidstr = talloc_asprintf(tc, "%u", (unsigned int)uid);
@@ -1801,13 +1808,6 @@ doma_done:
 
                sid_compose(&sid, get_global_sam_sid(), DOMAIN_RID_ADMINISTRATOR);
 
-               if (!winbind_allocate_uid(&uid)) {
-                       d_fprintf(stderr,
-                                 _("Unable to allocate a new uid to create "
-                                   "the Administrator user!\n"));
-                       goto done;
-               }
-
                smbldap_set_mod(&mods, LDAP_MOD_ADD, "objectClass", LDAP_OBJ_ACCOUNT);
                smbldap_set_mod(&mods, LDAP_MOD_ADD, "objectClass", LDAP_OBJ_POSIXACCOUNT);
                smbldap_set_mod(&mods, LDAP_MOD_ADD, "objectClass", LDAP_OBJ_SAMBASAMACCOUNT);