Re: Logon API on Windows 2000 with ASP.NET 1.1
From: Joe Kaplan \(MVP - ADSI\) (joseph.e.kaplan_at_removethis.accenture.com)
Date: 04/17/04
- Next message: Joe Kaplan \(MVP - ADSI\): "Re: A potentially dangerous querystring ... [ValidateRequest]"
- Previous message: Ken Schaefer: "Re: A potentially dangerous querystring ... [ValidateRequest]"
- In reply to: Rupreet Singh: "Re: Logon API on Windows 2000 with ASP.NET 1.1"
- Next in thread: jzhu: "Re: Logon API on Windows 2000 with ASP.NET 1.1"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Sat, 17 Apr 2004 12:19:59 -0500
You really really should be using the canonical example for calling
LogonUser via P/Invoke that MS published in the Framework SDK reference:
Your's is much less robust.
Also remember, under Win2K, the current account running the LogonUser code
MUST have the "Act as part of the operating system" privilege to call
LogonUser. You state that your ASP.NET 1.0 code works and that it is
running as SYSTEM. You need to ensure that you have similar privileges for
the account executing the code in 1.1 as well.
Note that you generally don't want to be running as SYSTEM (or any account
with Act as part of the operating system), so it might be good to consider
using a different security model for what you are trying to accomplish. If
you can more to Win2K3 server, this privilege restriction is lifted, so
perhaps that is an easy path for you.
HTH,
Joe K.
"Rupreet Singh" <anonymous@discussions.microsoft.com> wrote in message
news:F33BD8F2-934D-42CA-9064-11D1904FF27B@microsoft.com...
> Hi!
> Here is the code i used for logging.
>
> [DllImport(@"C:\Windows\System32\ADVAPI32.DLL",SetLastError=true)]
> public static extern bool LogonUser(string lpszUsername, string
lpszDomain, string lpszPassword, int dwLogonType, int dwLogonProvider, ref
IntPtr phToken);
>
> const int LOGON32_LOGON_NETWORK = 3;
> const int LOGON32_PROVIDER_DEFAULT = 0;
>
> IntPtr token1 = IntPtr.Zero;
> bool LoggedOn =
LogonUser(Username,DomainName,Password,LOGON32_LOGON_NETWORK,LOGON32_PROVIDE
R_DEFAULT,ref token1);
>
> But as i told you before, for Windows 2000, i always get "false" with
ASP.NET 1.1 but "true" with ASP.NET 1.0 (with SYSTEM Account) with the right
credentials.
>
> Thanks
> Rupreet Singh
>
- Next message: Joe Kaplan \(MVP - ADSI\): "Re: A potentially dangerous querystring ... [ValidateRequest]"
- Previous message: Ken Schaefer: "Re: A potentially dangerous querystring ... [ValidateRequest]"
- In reply to: Rupreet Singh: "Re: Logon API on Windows 2000 with ASP.NET 1.1"
- Next in thread: jzhu: "Re: Logon API on Windows 2000 with ASP.NET 1.1"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|