summaryrefslogtreecommitdiff
path: root/source3/smbd/reply.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/smbd/reply.c')
-rw-r--r--source3/smbd/reply.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 1b15639720..811a7558dc 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -906,18 +906,23 @@ int reply_sesssetup_and_X(connection_struct *conn, char *inbuf,char *outbuf,int
pstrcpy( orig_user, user);
- /* if the username exists as a domain/username pair on the unix system then use
- that */
- if (!sys_getpwnam(user)) {
- pstring user2;
-
- slprintf(user2,sizeof(user2)-1,"%s%s%s", dos_to_unix(domain,False),
- lp_winbind_separator(), user);
-
- if (sys_getpwnam(user2)) {
- DEBUG(3,("Using unix username %s\n", user2));
- pstrcpy(user, user2);
- }
+ /*
+ * Always try the "DOMAIN\user" lookup first, as this is the most
+ * specific case. If this fails then try the simple "user" lookup.
+ */
+
+ {
+ pstring dom_user;
+
+ /* Work out who's who */
+
+ slprintf(dom_user, sizeof(dom_user) - 1,"%s%s%s",
+ dos_to_unix(domain, False), lp_winbind_separator(), user);
+
+ if (sys_getpwnam(dom_user) != NULL) {
+ pstrcpy(user, dom_user);
+ DEBUG(3,("Using unix username %s\n", dom_user));
+ }
}
/*