I've been banging my head...I can't pretend to be a C++ guy...
TCHAR * pszUserName = userName.GetBuffer();
SID sid;
SecureZeroMemory(&sid, sizeof(sid));
SID_NAME_USE sidNameUse;
DWORD cbSid = sizeof(sid);
pLog->Log(_T("Getting the SID for user [%s]"), 1, userName);
if (!LookupAccountName(NULL, (LPSTR)pszUserName, &sid, &cbSid, NULL, 0, &sidNameUse))
{
pLog->Log(_T("Failed to look up user SID. Error code: %d"),1, GetLastError());
return _T("");
}
pLog->Log(_T("Converting binary SID to string SID"));
The message 'Getting the SID for user [x] is written' but then the app crashes. I'm assuming is was the LookupAccountName
call.
EDIT:
Whoops userName
is a MFC CString