Hans Leidekker : credui: Split domain from username in SspiPromptForCredentialsW.

Alexandre Julliard julliard at winehq.org
Wed Feb 1 15:26:07 CST 2017


Module: wine
Branch: master
Commit: 848f478091ed83b19e082af1ea451bf4ac06d5da
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=848f478091ed83b19e082af1ea451bf4ac06d5da

Author: Hans Leidekker <hans at codeweavers.com>
Date:   Wed Feb  1 14:18:48 2017 +0100

credui: Split domain from username in SspiPromptForCredentialsW.

Signed-off-by: Hans Leidekker <hans at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/credui/credui_main.c | 34 ++++++++++++++++++++++++++++------
 1 file changed, 28 insertions(+), 6 deletions(-)

diff --git a/dlls/credui/credui_main.c b/dlls/credui/credui_main.c
index b85129a..0da4643 100644
--- a/dlls/credui/credui_main.c
+++ b/dlls/credui/credui_main.c
@@ -910,23 +910,45 @@ ULONG SEC_ENTRY SspiPromptForCredentialsW( PCWSTR target, void *info,
     if (!(ret = CredUIPromptForCredentialsW( cred_info, target, NULL, error, username,
                                              len_username, password, len_password, save, flags )))
     {
-        DWORD size = sizeof(*id);
-        WCHAR *ptr;
+        DWORD size = sizeof(*id), len_domain = 0;
+        WCHAR *ptr, *user = username, *domain = NULL;
 
-        len_username = strlenW( username );
+        if ((ptr = strchrW( username, '\\' )))
+        {
+            user = ptr + 1;
+            len_username = strlenW( user );
+            if (!strcmpiW( package, ntlmW ) || !strcmpiW( package, negotiateW ))
+            {
+                domain = username;
+                len_domain = ptr - username;
+            }
+            *ptr = 0;
+        }
+        else len_username = strlenW( username );
         len_password = strlenW( password );
 
         size += (len_username + 1) * sizeof(WCHAR);
+        size += (len_domain + 1) * sizeof(WCHAR);
         size += (len_password + 1) * sizeof(WCHAR);
         if (!(id = HeapAlloc( GetProcessHeap(), 0, size ))) return ERROR_OUTOFMEMORY;
         ptr = (WCHAR *)(id + 1);
 
-        memcpy( ptr, username, (len_username + 1) * sizeof(WCHAR) );
+        memcpy( ptr, user, (len_username + 1) * sizeof(WCHAR) );
         id->User           = ptr;
         id->UserLength     = len_username;
         ptr += len_username + 1;
-        id->Domain         = NULL;
-        id->DomainLength   = 0;
+        if (len_domain)
+        {
+            memcpy( ptr, domain, (len_domain + 1) * sizeof(WCHAR) );
+            id->Domain         = ptr;
+            id->DomainLength   = len_domain;
+            ptr += len_domain + 1;
+        }
+        else
+        {
+            id->Domain         = NULL;
+            id->DomainLength   = 0;
+        }
         memcpy( ptr, password, (len_password + 1) * sizeof(WCHAR) );
         id->Password       = ptr;
         id->PasswordLength = len_password;




More information about the wine-cvs mailing list