summaryrefslogtreecommitdiff
path: root/source3/auth/auth_util.c
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2003-02-22 11:34:04 +0000
committerAndrew Bartlett <abartlet@samba.org>2003-02-22 11:34:04 +0000
commitab43a25b2893506d5de305626dfbbf98966f1f78 (patch)
tree653e18d5b5c979f86d04cc66ac09e2164b8ab189 /source3/auth/auth_util.c
parent4fdb86eb3b9b7eb01a90e3f3a846fb9f223d7208 (diff)
downloadsamba-ab43a25b2893506d5de305626dfbbf98966f1f78.tar.gz
samba-ab43a25b2893506d5de305626dfbbf98966f1f78.tar.bz2
samba-ab43a25b2893506d5de305626dfbbf98966f1f78.zip
First check if the user is in the passdb, then check Get_Pwnam().
We check passdb becouse the user might have things like a logon script set, but we have to check the passdb becouse the user might not be in smbpasswd at all. This is in preperation for the removal of unixsam as an assuption. Andrew Bartlett (This used to be commit 61e3e2695860c58f9b0e8d1856972318666682c8)
Diffstat (limited to 'source3/auth/auth_util.c')
-rw-r--r--source3/auth/auth_util.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/source3/auth/auth_util.c b/source3/auth/auth_util.c
index 352d058f20..7d85153bd0 100644
--- a/source3/auth/auth_util.c
+++ b/source3/auth/auth_util.c
@@ -78,6 +78,36 @@ void smb_user_control(const auth_usersupplied_info *user_info, auth_serversuppli
}
/****************************************************************************
+ Create a SAM_ACCOUNT - either by looking in the pdb, or by faking it up from
+ unix info.
+****************************************************************************/
+
+NTSTATUS auth_get_sam_account(const char *user, SAM_ACCOUNT **account)
+{
+ BOOL pdb_ret;
+ NTSTATUS nt_status;
+ if (!NT_STATUS_IS_OK(nt_status = pdb_init_sam(account))) {
+ return nt_status;
+ }
+
+ become_root();
+ pdb_ret = pdb_getsampwnam(*account, user);
+ unbecome_root();
+
+ if (!pdb_ret) {
+
+ struct passwd *pass = Get_Pwnam(user);
+ if (!pass)
+ return NT_STATUS_NO_SUCH_USER;
+
+ if (!NT_STATUS_IS_OK(nt_status = pdb_fill_sam_pw(*account, pass))) {
+ return nt_status;
+ }
+ }
+ return NT_STATUS_OK;
+}
+
+/****************************************************************************
Create an auth_usersupplied_data structure
****************************************************************************/