This patch allows net rpc vampire to create accounts in the same way
that smbpasswd does, i.e. it will attempt to use the appropriate
account creation function for the backend in use. From reading the
comments on the top of the local_password_change function, either I
shouldn't be going this route or local_password_change is due for some
sort of change in status. The only major caveat I've found is that
because net rpc vampire does a getpwnam_alloc() immediately after
account creation, which fails in my case because I'm using ldap_nua as
my backend so getpwnam_alloc() will /always/ fail.

Cheers,
Waider.

Index: source/utils/net_rpc_samsync.c
===================================================================
RCS file: /cvsroot/samba/source/utils/net_rpc_samsync.c,v
retrieving revision 1.16
diff -a -u -r1.16 net_rpc_samsync.c
--- source/utils/net_rpc_samsync.c      20 Dec 2002 20:23:06 -0000      1.16
+++ source/utils/net_rpc_samsync.c      21 Jan 2003 12:13:36 -0000
@@ -318,6 +318,24 @@
                        add_ret = smbrun(add_script,NULL);
                        DEBUG(1,("fetch_account: Running the command `%s' "
                                 "gave %d\n", add_script, add_ret));
+               } else {
+                 /* Need to add the user by other means */
+                 int local_flags = LOCAL_ADD_USER; /* XXX */
+                 BOOL ret;
+                 pstring err_str;
+                 pstring msg_str;
+
+                 ret = local_password_change( account, local_flags, "NEWPASS" /* XXX 
+*/, err_str, sizeof( err_str ), msg_str, sizeof(msg_str));
+                 if (*msg_str)
+                   printf( msg_str );
+                 if (*err_str)
+                   fprintf(stderr, err_str);
+                 if ( !ret ) {
+                   /* FIXME any other cleanup? */
+                   DEBUG(3, ("Could not create account %s\n", account));
+                   pdb_free_sam(&sam_account);
+                   return NT_STATUS_NO_SUCH_USER;
+                 }
                }
                pw = getpwnam_alloc(account);
                if (pw) {

-- 
[EMAIL PROTECTED] / Yes, it /is/ very personal of me.

"Life? hell, i haven't had time to do laundry. I'll get all sorts of life
 soon enough if that keeps up." - AjD
-- 
To unsubscribe from this list go to the following URL and read the
instructions:  http://lists.samba.org/mailman/listinfo/samba

Reply via email to