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));
+ }
}
/*