summaryrefslogtreecommitdiff
path: root/source3/libnet
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2009-04-01 18:52:28 +0200
committerGünther Deschner <gd@samba.org>2009-04-01 19:12:19 +0200
commite18f57fd36102212a3662823c58408da01d067ed (patch)
tree107c0ef128a4070dee594333a37418ec7e591b2d /source3/libnet
parentd0e1ff4aff24ef2f3b3f535ad25ad0573382e1a3 (diff)
downloadsamba-e18f57fd36102212a3662823c58408da01d067ed.tar.gz
s3-libnet-samsync: use smb_create_user().
Guenther
Diffstat (limited to 'source3/libnet')
-rw-r--r--source3/libnet/libnet_samsync_passdb.c52
1 files changed, 6 insertions, 46 deletions
diff --git a/source3/libnet/libnet_samsync_passdb.c b/source3/libnet/libnet_samsync_passdb.c
index 1b88758be21..96731ac5f4e 100644
--- a/source3/libnet/libnet_samsync_passdb.c
+++ b/source3/libnet/libnet_samsync_passdb.c
@@ -236,13 +236,12 @@ static NTSTATUS fetch_account_info(TALLOC_CTX *mem_ctx,
NTSTATUS nt_ret = NT_STATUS_UNSUCCESSFUL;
fstring account;
- char *add_script = NULL;
struct samu *sam_account=NULL;
GROUP_MAP map;
struct group *grp;
DOM_SID user_sid;
DOM_SID group_sid;
- struct passwd *passwd;
+ struct passwd *passwd = NULL;
fstring sid_string;
fstrcpy(account, r->account_name.string);
@@ -252,50 +251,11 @@ static NTSTATUS fetch_account_info(TALLOC_CTX *mem_ctx,
return NT_STATUS_NO_MEMORY;
}
- if (!(passwd = Get_Pwnam_alloc(sam_account, account))) {
- /* Create appropriate user */
- if (r->acct_flags & ACB_NORMAL) {
- add_script = talloc_strdup(sam_account,
- lp_adduser_script());
- } else if ( (r->acct_flags & ACB_WSTRUST) ||
- (r->acct_flags & ACB_SVRTRUST) ||
- (r->acct_flags & ACB_DOMTRUST) ) {
- add_script = talloc_strdup(sam_account,
- lp_addmachine_script());
- } else {
- DEBUG(1, ("Unknown user type: %s\n",
- pdb_encode_acct_ctrl(r->acct_flags, NEW_PW_FORMAT_SPACE_PADDED_LEN)));
- nt_ret = NT_STATUS_UNSUCCESSFUL;
- goto done;
- }
- if (!add_script) {
- nt_ret = NT_STATUS_NO_MEMORY;
- goto done;
- }
- if (*add_script) {
- int add_ret;
- add_script = talloc_all_string_sub(sam_account,
- add_script,
- "%u",
- account);
- if (!add_script) {
- nt_ret = NT_STATUS_NO_MEMORY;
- goto done;
- }
- add_ret = smbrun(add_script,NULL);
- DEBUG(add_ret ? 0 : 1,("fetch_account: Running the command `%s' "
- "gave %d\n", add_script, add_ret));
- if (add_ret == 0) {
- smb_nscd_flush_user_cache();
- }
- }
-
- /* try and find the possible unix account again */
- if ( !(passwd = Get_Pwnam_alloc(sam_account, account)) ) {
- d_fprintf(stderr, "Could not create posix account info for '%s'\n", account);
- nt_ret = NT_STATUS_NO_SUCH_USER;
- goto done;
- }
+ nt_ret = smb_create_user(sam_account, r->acct_flags, account, &passwd);
+ if (!NT_STATUS_IS_OK(nt_ret)) {
+ d_fprintf(stderr, "Could not create posix account info for '%s'\n",
+ account);
+ goto done;
}
sid_copy(&user_sid, get_global_sam_sid());