From 3812a973cd6c8329ce18802a7c5bb980308ae87a Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Sun, 9 May 2004 05:39:05 +0000 Subject: [PATCH] user-instance-20040508 Enable afscreds.exe to support instance components of usernames for non-kfw token retrieval --- src/WINNT/client_creds/creds.cpp | 37 ++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/src/WINNT/client_creds/creds.cpp b/src/WINNT/client_creds/creds.cpp index 40447fa22..59cca63b1 100644 --- a/src/WINNT/client_creds/creds.cpp +++ b/src/WINNT/client_creds/creds.cpp @@ -401,23 +401,28 @@ int ObtainNewCredentials (LPCTSTR pszCell, LPCTSTR pszUser, LPCTSTR pszPassword, int Expiration = 0; - char name[sizeof(szNameA)]; - char instance[sizeof(szNameA)]; - char cell[sizeof(szNameA)]; + if ( KFW_is_available() ) { + // KFW_AFS_get_cred() parses the szNameA field as complete princial including potentially + // a different realm then the specified cell name. + rc = KFW_AFS_get_cred(szNameA, szCellA, szPasswordA, 0, szSmbNameA[0] ? szSmbNameA : NULL, &Result); + } else { + char name[sizeof(szNameA)]; + char instance[sizeof(szNameA)]; + char cell[sizeof(szNameA)]; - name[0] = '\0'; - instance[0] = '\0'; - cell[0] = '\0'; - ka_ParseLoginName(szNameA, name, instance, cell); - - if ( KFW_is_available() ) - rc = KFW_AFS_get_cred(name, instance, szCellA, szPasswordA, 0, szSmbNameA[0] ? szSmbNameA : NULL, &Result); - else if ( szSmbNameA[0] ) - rc = ka_UserAuthenticateGeneral2(KA_USERAUTH_VERSION+KA_USERAUTH_AUTHENT_LOGON, - name, instance, szCellA, szPasswordA, szSmbNameA, 0, &Expiration, 0, &Result); - else - rc = ka_UserAuthenticateGeneral(KA_USERAUTH_VERSION, name, instance, szCellA, szPasswordA, 0, &Expiration, 0, &Result); - } + name[0] = '\0'; + instance[0] = '\0'; + cell[0] = '\0'; + ka_ParseLoginName(szNameA, name, instance, cell); + + if ( szSmbNameA[0] ) { + rc = ka_UserAuthenticateGeneral2(KA_USERAUTH_VERSION+KA_USERAUTH_AUTHENT_LOGON, + name, instance, szCellA, szPasswordA, szSmbNameA, 0, &Expiration, 0, &Result); + } else { + rc = ka_UserAuthenticateGeneral(KA_USERAUTH_VERSION, name, instance, szCellA, szPasswordA, 0, &Expiration, 0, &Result); + } + } + } if (!Silent && rc != 0) { -- 2.39.5