summaryrefslogtreecommitdiff
path: root/source3/passdb/passdb.c
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2001-12-30 00:03:47 +0000
committerGerald Carter <jerry@samba.org>2001-12-30 00:03:47 +0000
commit98010a076797f4d05d8c9bff45e65c076f30da3a (patch)
treecda0a7bc2efc710bc8937113cf4104058c433f67 /source3/passdb/passdb.c
parent49e66e1352952fe4bfe363c7effe2052ae6da8b8 (diff)
downloadsamba-98010a076797f4d05d8c9bff45e65c076f30da3a.tar.gz
samba-98010a076797f4d05d8c9bff45e65c076f30da3a.tar.bz2
samba-98010a076797f4d05d8c9bff45e65c076f30da3a.zip
pdb_getsampwnuid() merge from 2.2
(This used to be commit 54cbfc7ebcdf1bd2094407b689b0050f0abfa46f)
Diffstat (limited to 'source3/passdb/passdb.c')
-rw-r--r--source3/passdb/passdb.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/source3/passdb/passdb.c b/source3/passdb/passdb.c
index ca7c508dc5..eeecc0abe5 100644
--- a/source3/passdb/passdb.c
+++ b/source3/passdb/passdb.c
@@ -1793,4 +1793,33 @@ BOOL pdb_set_plaintext_passwd (SAM_ACCOUNT *sampass, const char *plaintext)
return True;
}
+/***************************************************************************
+ Search by uid. Wrapper around pdb_getsampwnam()
+ **************************************************************************/
+
+BOOL pdb_getsampwuid (SAM_ACCOUNT* user, uid_t uid)
+{
+ struct passwd *pw;
+ fstring name;
+
+ if (user==NULL) {
+ DEBUG(0,("pdb_getsampwuid: SAM_ACCOUNT is NULL.\n"));
+ return False;
+ }
+
+ /*
+ * Never trust the uid in the passdb. Lookup the username first
+ * and then lokup the user by name in the sam.
+ */
+
+ if ((pw=sys_getpwuid(uid)) == NULL) {
+ DEBUG(0,("pdb_getsampwuid: getpwuid(%d) return NULL. User does not exist in Unix accounts!\n", uid));
+ return False;
+ }
+
+ fstrcpy (name, pw->pw_name);
+
+ return pdb_getsampwnam (user, name);
+
+}