Skip to content

Commit 241e256

Browse files
committed
ee/wcp: switch to using LSA
1 parent c1c1a9a commit 241e256

3 files changed

Lines changed: 7 additions & 25 deletions

File tree

ee/wcp/ak_cred_provider/Credential.cpp

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -247,13 +247,13 @@ LRESULT APIENTRY Credential::WndProc(_In_ HWND hWnd, _In_ UINT uMsg, _In_ WPARAM
247247
.c_str());
248248
if ((m_oCefAppData.pCefApp)) {
249249
spdlog::debug("WndProc:: CEFLaunch");
250-
pData->strUsername = "";
250+
pData->strUserToken = "";
251251
try {
252252
CEFLaunch(pData, m_oCefAppData.pCefApp);
253253
} catch (const std::exception& e) {
254254
spdlog::warn("Failed to CEFLaunch", e.what());
255255
}
256-
spdlog::debug(std::string("User logged in: " + pData->strUsername).c_str());
256+
spdlog::debug(std::string("User logged in: " + pData->strUserToken).c_str());
257257
spdlog::debug("WndProc:: CEFLaunched");
258258
} else {
259259
::MessageBox(hWnd,
@@ -545,25 +545,7 @@ IFACEMETHODIMP Credential::Connect(IQueryContinueWithStatus* pqcws) {
545545
} else {
546546
strCredUser = std::wstring(m_pszQualifiedUserName);
547547
}
548-
std::wstring strAuthUser =
549-
std::wstring(m_oHookData.strUsername.begin(), m_oHookData.strUsername.end());
550-
if ((strAuthUser == strCredUser) && (strCredUser != L"")) {
551-
// Reset password
552-
USER_INFO_1003 oUserInfo1003;
553-
DWORD dwParamErr = 0;
554-
m_strPass = GetRandomWStr(WIN_PASS_LEN);
555-
oUserInfo1003.usri1003_password = (LPWSTR)(m_strPass.c_str());
556-
if (NetUserSetInfo(NULL, strCredUser.c_str(), 1003, (LPBYTE)(&oUserInfo1003), &dwParamErr) !=
557-
NERR_Success) {
558-
hr = E_FAIL;
559-
}
560-
} else {
561-
if (strAuthUser != L"") {
562-
MessageBox(hwndOwner, std::wstring(L"Username mismatch.").c_str(),
563-
(LPCWSTR)L"Login Failure", MB_OK | MB_TASKMODAL);
564-
}
565-
hr = E_FAIL;
566-
}
548+
m_strPass = utf8_decode(m_oHookData.strUserToken);
567549
} else {
568550
hr = E_POINTER;
569551
}

ee/wcp/ak_cred_provider/Helpers.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ HRESULT RetrieveNegotiateAuthPackage(_Out_ ULONG* pulAuthPackage) {
303303
if (SUCCEEDED(HRESULT_FROM_NT(status))) {
304304
ULONG ulAuthPackage;
305305
LSA_STRING lsaszKerberosName;
306-
_LsaInitString(&lsaszKerberosName, NEGOSSP_NAME_A);
306+
_LsaInitString(&lsaszKerberosName, "ak_lsa");
307307

308308
status = LsaLookupAuthenticationPackage(hLsa, &lsaszKerberosName, &ulAuthPackage);
309309
if (SUCCEEDED(HRESULT_FROM_NT(status))) {

ee/wcp/ak_cred_provider/include/Credential.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ struct sHookData {
2222
hInstance = phInstance;
2323
oMutex.unlock();
2424
}
25-
void UpdateUser(const std::string& strUser) {
25+
void UpdateUserToken(const std::string& strUser) {
2626
oMutex.lock();
27-
strUsername = strUser;
27+
strUserToken = strUser;
2828
oMutex.unlock();
2929
}
3030
void UpdateHeaderToken(const std::string& headerToken) {
@@ -97,7 +97,7 @@ struct sHookData {
9797
}
9898
PWSTR UserSid = NULL;
9999
HINSTANCE hInstance = NULL;
100-
std::string strUsername = "";
100+
std::string strUserToken = "";
101101
std::string strHeaderToken = "";
102102
bool bExit = false; // flag to exit the custom loop
103103
bool bComplete = false; // UI call complete

0 commit comments

Comments
 (0)