Thread: LogonUser() API blocks with wrong credentials

  1. #1
    Registered User
    Join Date
    Apr 2009
    Posts
    1

    LogonUser() API blocks with wrong credentials

    Hi,

    We are using Windows APIs to impersonate a user in an application that runs as a service. The service under which the application is running is started with Logon as Local System Account.

    The Local System account has all the privileges required for impersonation. After providing correct credentials, the application is able to logon as a service and do successful impersonation.

    However, if the password passed to LogonUser() API is incorrect, the call is blocked/hanging. It is expected that the API returns failure but it should not hang. Is this a known issue or is something wrong?

    We are using OS: Windows XP

    Here are the details for impersonation-

    For impersonation we are calling LogonUser() API

    LogonUser(mailbox,domain,m_szPassword,
    LOGON32_LOGON_SERVICE,
    LOGON32_PROVIDER_DEFAULT,
    &hToken))

    Steps followed for impersonation are as follows-

    1. LookupPrivilegeValue for SE_TCB_NAME
    2. OpenProcessToken
    3. AdjustTokenPrivileges
    4. LogonUser
    5. LoadUserProfile
    6. ImpersonateLoggedOnUser

    Any pointers will be helpful!

    Thanks,
    Neha

  2. #2
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Have you tried attaching to your service with WinDbg or similar to see where it's actually hanging? Make sure you have the Windows debug symbols installed, or set the environment variable "_NT_SYMBOL_PATH=SRV*C:\symbols*http://msdl.microsoft.com/download/symbols"

    (Obviously, it's hanging somewhere inside Windows, not your service -- this should help determine exactly where and possibly why)
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. FILES in WinAPI
    By Garfield in forum Windows Programming
    Replies: 46
    Last Post: 10-02-2003, 06:51 PM
  2. God
    By datainjector in forum A Brief History of Cprogramming.com
    Replies: 746
    Last Post: 12-22-2002, 12:01 PM

Tags for this Thread