LogonUser failed with error code : 1314

Ask a Question related to ASP.NET Security, Design and Development.

  1. #1

    Default LogonUser failed with error code : 1314

    Im trying to programmatically authenticate a user against NT under windows
    2000. I use the LogonUser API. Realizing that the call needs SYSTEM
    privileges, I created a COM+ component and run it under the administrator
    user. However, I still get the above error!. I have even checked
    WindowsIdentity.GetCurrent().Name and it returns administrator.

    ps: it works on my machine (windows xp pro)

    Any feedback greatly appreciated.
    Lee


    Lee Simpson Guest

  2. Similar Questions and Discussions

    1. Assert failed in c code
      Hi While testing on our dev enviroment we came accross the following error message in the admin.00.log Assert failed in...
    2. Error 403 Failed to read heders Error for long-runningCFMAIL and CFINDEX command
      I have two different pages with long-running scripts on which I am recieving the following error: Error - 403 Failed to read headers to server:...
    3. LogonUser failed error
      When I run my application , the LogonUser method fails the exception is "LogonUser failed with error code :1314". I know the error is because of...
    4. Subject: Method '~' of object '~' failed (Error Code: -2147417848 / 0x80010108)
      We have a strange and very disturbing problem: Every view hours a vb6 web application fails with the following error: Error Message: Method '~'...
    5. Compiler Error Message: The compiler failed with error code 128.
      Hi. I am having trouble running my aspx code. I created two simple webforms, which i try to run from two different directories one is giving me...
  3. #2

    Default Re: LogonUser failed with error code : 1314

    Solved my problem, and am posting the code here for others to benefit...

    using System.Management;
    using System.Runtime.InteropServices;

    public enum LogonType : int
    {
    LOGON32_LOGON_INTERACTIVE = 2,
    LOGON32_LOGON_NETWORK = 3,
    LOGON32_LOGON_BATCH = 4,
    LOGON32_LOGON_SERVICE = 5,
    LOGON32_LOGON_UNLOCK = 7,
    LOGON32_LOGON_NETWORK_CLEARTEXT = 8, // Only for Win2K or higher
    LOGON32_LOGON_NEW_CREDENTIALS = 9 // Only for Win2K or higher
    };

    public enum LogonProvider : int
    {
    LOGON32_PROVIDER_DEFAULT = 0,
    LOGON32_PROVIDER_WINNT35 = 1,
    LOGON32_PROVIDER_WINNT40 = 2,
    LOGON32_PROVIDER_WINNT50 = 3
    }
    ;
    [DllImport("advapi32.dll", SetLastError=true)]
    public static extern bool LogonUser(String lpszUsername, String lpszDomain,
    String lpszPassword,
    int dwLogonType, int dwLogonProvider, ref IntPtr TokenHandle);

    public bool Login(string Domain, string UserName, string Password)
    {
    ManagementObject mo = new ManagementObject(new ManagementPath( ));
    mo.Scope.Options.EnablePrivileges = true;

    IntPtr tokenHandle = IntPtr.Zero;
    return LogonUser(
    UserName,
    Domain,
    Password,
    (int)LogonType.LOGON32_LOGON_INTERACTIVE,
    (int)LogonProvider.LOGON32_PROVIDER_DEFAULT,
    ref tokenHandle);
    }

    The magic happens here:
    ManagementObject mo = new ManagementObject(new ManagementPath( ));
    mo.Scope.Options.EnablePrivileges = true;
    It enables the TCB privilege for you to execute the LogonUser command. I
    chose to use WMI, as it saves around 9 API calls.

    Lee Simpson


    "Lee Simpson" <leewsimpson[nospam]@hotmail.com> wrote in message
    news:btjv40$i5e$1@ctb-nnrp2.saix.net...
    > Im trying to programmatically authenticate a user against NT under windows
    > 2000. I use the LogonUser API. Realizing that the call needs SYSTEM
    > privileges, I created a COM+ component and run it under the administrator
    > user. However, I still get the above error!. I have even checked
    > WindowsIdentity.GetCurrent().Name and it returns administrator.
    >
    > ps: it works on my machine (windows xp pro)
    >
    > Any feedback greatly appreciated.
    > Lee
    >
    >

    Lee Simpson Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139