Re: How to Validate User Credentials on Windows 2000 OS?



I have tried this link out, but it is not working. Actually the code seems to
be not working. Here is the code which i had use:

UINT flags = TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY;
HANDLE hToken;
BOOL ret = OpenProcessToken(GetCurrentProcess(), flags, &hToken);
if(ret == TRUE)
{
LUID id;
BOOL ret1 = LookupPrivilegeValue(NULL, SE_TCB_NAME, &id);
if(ret1 == TRUE)
{
TOKEN_PRIVILEGES newPrivileges;
newPrivileges.PrivilegeCount = 1;
newPrivileges.Privileges[0].Luid = id;
newPrivileges.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;

BOOL ret2 = AdjustTokenPrivileges(hToken, FALSE, &newPrivileges, 0, NULL, 0);

if(ret2 == FALSE)
{
printf("AdjustTokenPrivileges failed. GetLastError() return = %d",
GetLastError());
}
else
{
HANDLE hUserToken;
if(LogonUser("asif", "OSA", "asif", LOGON32_LOGON_NETWORK,
LOGON32_PROVIDER_DEFAULT, &hUserToken))
{
CloseHandle(hUserToken);
return TRUE;
}
else
{
printf("LogonUser failed. GetLastError() return = %d",
GetLastError());
}


}
else
{
printf("LookupPrivilegeValue failed. GetLastError() return = %d",
GetLastError());
}
}
else
{
printf("OpenProcessToken failed. GetLastError() return = %d",
GetLastError());
}

Can you please check this code out?

Thanks
-Asif

"Alex Fedotov" wrote:

Asif Bhimla wrote:

I want to validate a user credentials using LogonUser(...) API, in an
administrator session on Windows 2000 platform. I have tried to Add
SE_TCB_NAME privilege to the process who is callin LogonUser(...) API, but
still I am unable to verify user Credentials on Windows 2000.

Can some one provide me code snippets which uses LogonUser(...) API on
Windows 2000 succesfully?

http://support.microsoft.com/default.aspx?scid=kb;en-us;180548

-- Alex Fedotov



.



Relevant Pages

  • Re: Do windows services have to run under an administrative accoun
    ... If I put GetLastError as the first code line on the ... Like William said, ... You call an API and the API returns nonzero in case of succcess and ...
    (microsoft.public.win32.programmer.kernel)
  • Re: CreateDirectory fails but GetLastError says succeeded
    ... Microsoft MVP-Visual Basic Fear and Loathing in LasVegas ... you cannot use GetLastError from VB because VB calls ... To get the error info you are ... >What happens is that the VB runtime is itself using API calls all the ...
    (microsoft.public.vb.winapi)
  • Re: Pinvoke and Win32 level API permissions
    ... You should not call GetLastError when using PInvoke, ... | call to the HrESEBackupPreparefunction in the Exchange backup API. ...
    (microsoft.public.dotnet.framework)
  • Re: GetLastError vs GetLastWin32Error
    ... If I use the Win32 API GetLastError() it returns ERROR_ACCESS_DENIED, but if I use the .NET Marshall.GetLastWin32Errorit returns ERROR_IO_PENDING. ... To get around this Marshal.GetLastWin32Errorhas been provided: the marshalling code saves the value of GetLastError immediately after it makes a call to the actual API so that your code is free to look at the error returned without worrying about those uncontrollable calls the CLR is making. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: LoadLibraryEx (as datafile) and MorIcons.dll - extracting icons
    ... >> Immediately after the failing LoadLibraryEx() call, call GetLastError() ... > resources in files that Windows offers in a default install ... ... > Any idea what I can do to access resources in NE-style executables (DLL's, ...
    (microsoft.public.win32.programmer.tools)

Quantcast