Ask a Question related to ASP.NET Security, Design and Development.
-
Lee Simpson #1
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
-
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... -
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:... -
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... -
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 '~'... -
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... -
Lee Simpson #2
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



Reply With Quote

