LogonUser() API blocks with wrong credentials

This is a discussion on LogonUser() API blocks with wrong credentials within the Windows Programming forums, part of the Platform Specific Boards category; Hi, We are using Windows APIs to impersonate a user in an application that runs as a service. The service ...

  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
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,246
    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, 11:01 AM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21