r23779: Change from v2 or later to v3 or later.
[jra/samba/.git] / source3 / utils / net_rpc_samsync.c
index 1337c11eca1500b2250b7d8bf9f161bb33799bec..bce1fd8f94d526971adbcff2c03707b58c0af9de 100644 (file)
@@ -10,7 +10,7 @@
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
@@ -29,7 +29,7 @@
 /* uid's and gid's for writing deltas to ldif */
 static uint32 ldif_gid = 999;
 static uint32 ldif_uid = 999;
-/* Kkeep track of ldap initialization */
+/* Keep track of ldap initialization */
 static int init_ldap = 1;
 
 static void display_group_mem_info(uint32 rid, SAM_GROUP_MEM_INFO *g)
@@ -212,7 +212,7 @@ static void dump_database(struct rpc_pipe_client *pipe_hnd, uint32 db_type)
                result = rpccli_netlogon_sam_sync(pipe_hnd, mem_ctx, db_type,
                                               sync_context,
                                               &num_deltas, &hdr_deltas, &deltas);
-               if (NT_STATUS_IS_ERR(result))
+               if (!NT_STATUS_IS_OK(result))
                        break;
 
                 for (i = 0; i < num_deltas; i++) {
@@ -670,10 +670,14 @@ static NTSTATUS fetch_group_mem_info(uint32 rid, SAM_GROUP_MEM_INFO *delta)
                return NT_STATUS_NO_MEMORY;
        }
 
-       if ((nt_members = TALLOC_ZERO_ARRAY(t, char *, delta->num_members)) == NULL) {
-               DEBUG(0, ("talloc failed\n"));
-               talloc_free(t);
-               return NT_STATUS_NO_MEMORY;
+       if (delta->num_members) {
+               if ((nt_members = TALLOC_ZERO_ARRAY(t, char *, delta->num_members)) == NULL) {
+                       DEBUG(0, ("talloc failed\n"));
+                       talloc_free(t);
+                       return NT_STATUS_NO_MEMORY;
+               }
+       } else {
+               nt_members = NULL;
        }
 
        for (i=0; i<delta->num_members; i++) {
@@ -1104,37 +1108,6 @@ static NTSTATUS populate_ldap_for_ldif(fstring sid, const char *suffix, const ch
                fflush(add_fd);
        }
 
-       /* Write the root entity */
-       fprintf(add_fd, "# root, %s, %s\n", user_attr, suffix);
-       fprintf(add_fd, "dn: uid=root,ou=%s,%s\n", user_attr, suffix);
-       fprintf(add_fd, "cn: root\n");
-       fprintf(add_fd, "sn: root\n");
-       fprintf(add_fd, "objectClass: inetOrgPerson\n");
-       fprintf(add_fd, "objectClass: sambaSAMAccount\n");
-       fprintf(add_fd, "objectClass: posixAccount\n");
-       fprintf(add_fd, "objectClass: shadowAccount\n");
-       fprintf(add_fd, "gidNumber: 0\n");
-       fprintf(add_fd, "uid: root\n");
-       fprintf(add_fd, "uidNumber: 0\n");
-       fprintf(add_fd, "homeDirectory: /home/root\n");
-       fprintf(add_fd, "sambaPwdLastSet: 0\n");
-       fprintf(add_fd, "sambaLogonTime: 0\n");
-       fprintf(add_fd, "sambaLogoffTime: 2147483647\n");
-       fprintf(add_fd, "sambaKickoffTime: 2147483647\n");
-       fprintf(add_fd, "sambaPwdCanChange: 0\n");
-       fprintf(add_fd, "sambaPwdMustChange: 2147483647\n");
-       fprintf(add_fd, "sambaHomePath: \\\\PDC-SRV\\root\n");
-       fprintf(add_fd, "sambaHomeDrive: H:\n");
-       fprintf(add_fd, "sambaProfilePath: \\\\PDC-SRV\\profiles\\root\n");
-       fprintf(add_fd, "sambaprimaryGroupSID: %s-512\n", sid);
-       fprintf(add_fd, "sambaLMPassword: XXX\n");
-       fprintf(add_fd, "sambaNTPassword: XXX\n");
-       fprintf(add_fd, "sambaAcctFlags: [U\n");
-       fprintf(add_fd, "sambaSID: %s-500\n", sid);
-       fprintf(add_fd, "loginShell: /bin/false\n");
-       fprintf(add_fd, "\n");
-       fflush(add_fd);
-
        /* Write the domain entity */
        fprintf(add_fd, "# %s, %s\n", lp_workgroup(), suffix);
        fprintf(add_fd, "dn: sambaDomainName=%s,%s\n", lp_workgroup(),
@@ -1148,37 +1121,6 @@ static NTSTATUS populate_ldap_for_ldif(fstring sid, const char *suffix, const ch
        fprintf(add_fd, "\n");
        fflush(add_fd);
 
-       /* Write user nobody entity */
-       fprintf(add_fd, "# nobody, %s, %s\n", user_attr, suffix);
-       fprintf(add_fd, "dn: uid=nobody,ou=%s,%s\n", user_attr, suffix);
-       fprintf(add_fd, "cn: nobody\n");
-       fprintf(add_fd, "sn: nobody\n");
-       fprintf(add_fd, "objectClass: inetOrgPerson\n");
-       fprintf(add_fd, "objectClass: sambaSAMAccount\n");
-       fprintf(add_fd, "objectClass: posixAccount\n");
-       fprintf(add_fd, "objectClass: shadowAccount\n");
-       fprintf(add_fd, "gidNumber: 514\n");
-       fprintf(add_fd, "uid: nobody\n");
-       fprintf(add_fd, "uidNumber: 999\n");
-       fprintf(add_fd, "homeDirectory: /nobodyshomedir\n");
-       fprintf(add_fd, "sambaPwdLastSet: 0\n");
-       fprintf(add_fd, "sambaLogonTime: 0\n");
-       fprintf(add_fd, "sambaLogoffTime: 2147483647\n");
-       fprintf(add_fd, "sambaKickoffTime: 2147483647\n");
-       fprintf(add_fd, "sambaPwdCanChange: 0\n");
-       fprintf(add_fd, "sambaPwdMustChange: 2147483647\n");
-       fprintf(add_fd, "sambaHomePath: \\\\PDC-SMD3\\homes\\nobody\n");
-       fprintf(add_fd, "sambaHomeDrive: H:\n");
-       fprintf(add_fd, "sambaProfilePath: \\\\PDC-SMB3\\profiles\\nobody\n");
-       fprintf(add_fd, "sambaprimaryGroupSID: %s-514\n", sid);
-       fprintf(add_fd, "sambaLMPassword: NOPASSWORDXXXXXXXXXXXXXXXXXXXXX\n");
-       fprintf(add_fd, "sambaNTPassword: NOPASSWORDXXXXXXXXXXXXXXXXXXXXX\n");
-       fprintf(add_fd, "sambaAcctFlags: [NU\n");
-       fprintf(add_fd, "sambaSID: %s-2998\n", sid);
-       fprintf(add_fd, "loginShell: /bin/false\n");
-       fprintf(add_fd, "\n");
-       fflush(add_fd);
-
        /* Write the Domain Admins entity */ 
        fprintf(add_fd, "# Domain Admins, %s, %s\n", group_attr,
                suffix);
@@ -1598,13 +1540,8 @@ static NTSTATUS fetch_account_info_to_ldif(SAM_DELTA_CTR *delta,
        }
        unix_time = nt_time_to_unix(delta->account_info.pwd_last_set_time);
 
-       /* The nobody user is entered by populate_ldap_for_ldif */
-       if (strcmp(username, "nobody") == 0) {
-               return NT_STATUS_OK;
-       } else {
-               /* Increment the uid for the new user */
-               ldif_uid++;
-       }
+       /* Increment the uid for the new user */
+       ldif_uid++;
 
        /* Set up group id and sambaSID for the user */
        group_rid = delta->account_info.group_rid;