diff options
author | Jeremy Allison <jra@samba.org> | 2009-04-01 14:03:17 -0700 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2009-04-01 14:03:17 -0700 |
commit | aef0bdc6a1ffdf746ce9ce27c45b3ca4f6593ba9 (patch) | |
tree | fc5fc5852fc59fd41536ca33cae3ebe0b2b330c2 /source3/passdb | |
parent | eaddcfef1ba553744ae9293feaf7585ec9aaa0db (diff) | |
parent | 01a942d8ab5b5e430eb928dd58626fe16b9b04fe (diff) | |
download | samba-aef0bdc6a1ffdf746ce9ce27c45b3ca4f6593ba9.tar.gz samba-aef0bdc6a1ffdf746ce9ce27c45b3ca4f6593ba9.tar.bz2 samba-aef0bdc6a1ffdf746ce9ce27c45b3ca4f6593ba9.zip |
Merge branch 'master' of ssh://jra@git.samba.org/data/git/samba
Diffstat (limited to 'source3/passdb')
-rw-r--r-- | source3/passdb/passdb.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/source3/passdb/passdb.c b/source3/passdb/passdb.c index 95e5deb36f..fd715d201f 100644 --- a/source3/passdb/passdb.c +++ b/source3/passdb/passdb.c @@ -2348,3 +2348,62 @@ struct samr_LogonHours get_logon_hours_from_pdb(TALLOC_CTX *mem_ctx, return hours; } +/**************************************************************** +****************************************************************/ + +NTSTATUS smb_create_user(TALLOC_CTX *mem_ctx, + uint32_t acct_flags, + const char *account, + struct passwd **passwd_p) +{ + struct passwd *passwd; + char *add_script = NULL; + + passwd = Get_Pwnam_alloc(mem_ctx, account); + if (passwd) { + *passwd_p = passwd; + return NT_STATUS_OK; + } + + /* Create appropriate user */ + if (acct_flags & ACB_NORMAL) { + add_script = talloc_strdup(mem_ctx, lp_adduser_script()); + } else if ( (acct_flags & ACB_WSTRUST) || + (acct_flags & ACB_SVRTRUST) || + (acct_flags & ACB_DOMTRUST) ) { + add_script = talloc_strdup(mem_ctx, lp_addmachine_script()); + } else { + DEBUG(1, ("Unknown user type: %s\n", + pdb_encode_acct_ctrl(acct_flags, NEW_PW_FORMAT_SPACE_PADDED_LEN))); + return NT_STATUS_UNSUCCESSFUL; + } + + if (!add_script) { + return NT_STATUS_NO_MEMORY; + } + + if (*add_script) { + int add_ret; + add_script = talloc_all_string_sub(mem_ctx, add_script, + "%u", account); + if (!add_script) { + return NT_STATUS_NO_MEMORY; + } + 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 */ + passwd = Get_Pwnam_alloc(mem_ctx, account); + if (!passwd) { + return NT_STATUS_NO_SUCH_USER; + } + + *passwd_p = passwd; + + return NT_STATUS_OK; +} |