* add a few useful debug lines
authorGerald Carter <jerry@samba.org>
Fri, 19 Dec 2003 00:33:09 +0000 (00:33 +0000)
committerGerald Carter <jerry@samba.org>
Fri, 19 Dec 2003 00:33:09 +0000 (00:33 +0000)
* fix bug involving Win9x clients.  Make sure we
  save the right case for the located username
  in fill_sam_account()
(This used to be commit 850e4be29e185ebe890f094372aa8c2cc86de76a)

source3/auth/auth_util.c
source3/auth/auth_winbind.c

index 3dc0fdbe4640312b1f0a2f5d1529c8189389cc39..c4740496172729a6afddf64ee056b1f22fef5fe5 100644 (file)
@@ -926,21 +926,38 @@ static NTSTATUS fill_sam_account(TALLOC_CTX *mem_ctx,
        fstring dom_user;
        struct passwd *passwd;
 
-       fstr_sprintf(dom_user, "%s%s%s",
-                    domain, lp_winbind_separator(), username);
+       fstr_sprintf(dom_user, "%s%s%s", domain, lp_winbind_separator(), 
+               username);
 
        passwd = Get_Pwnam(dom_user);
+       
+       if ( passwd ) {
+               char *p;
+               
+               /* make sure we get the case of the username correct */
+               /* work around 'winbind use default domain = yes' */
+               
+               p = strchr( passwd->pw_name, *lp_winbind_separator() );
+               if ( !p ) 
+                       fstr_sprintf(dom_user, "%s%s%s", domain, 
+                               lp_winbind_separator(), passwd->pw_name);
+               else 
+                       fstrcpy( dom_user, passwd->pw_name );
+       }
+       else {
+               /* if the lookup for DOMAIN\username failed, try again 
+                  with just 'username'.  This is need for accessing the server
+                  as a trust user that actually maps to a local account */
 
-       /* if the lookup for DOMAIN\username failed, try again 
-          with just 'username'.  This is need for accessing the server
-          as a trust user that actually maps to a local account */
-
-       if ( !passwd ) {
                fstrcpy( dom_user, username );
                passwd = Get_Pwnam( dom_user );
+               
+               /* make sure we get the case of the username correct */
+               if ( passwd )
+                       fstrcpy( dom_user, passwd->pw_name );
        }
 
-       if (passwd == NULL)
+       if ( !passwd )
                return NT_STATUS_NO_SUCH_USER;
 
        *uid = passwd->pw_uid;
@@ -953,6 +970,9 @@ static NTSTATUS fill_sam_account(TALLOC_CTX *mem_ctx,
                                         --jerry              */
           
        *found_username = talloc_strdup(mem_ctx, dom_user);
+       
+       DEBUG(5,("fill_sam_account: located username was [%s]\n",
+               *found_username));
 
        return pdb_init_sam_pw(sam_account, passwd);
 }
index d09987ba37a5adcc8f32073b69fa6c24881a21d1..0e2820313e35bb57999b913faea60b2d2b76a97a 100644 (file)
@@ -76,7 +76,8 @@ static NTSTATUS check_winbind_security(const struct auth_context *auth_context,
        }               
 
        if (strequal(user_info->domain.str, get_global_sam_name())) {
-               DEBUG(3,("check_winbind_security: Not using winbind, requested domain was for this SAM.\n"));
+               DEBUG(3,("check_winbind_security: Not using winbind, requested domain [%s] was for this SAM.\n",
+                       user_info->domain.str));
                return NT_STATUS_NOT_IMPLEMENTED;
        }