Logon API on Windows 2000 with ASP.NET 1.1

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

  1. #1

    Default Logon API on Windows 2000 with ASP.NET 1.1

    Hi Everyone
    I’m working Windows 2000 Professional with IIS 5.0 and Framework 1.1.
    In my current project, I had to use Windows Authentication. The problem is that even if I use right credentials, the LogonUser Function (P/Invoke) always return false. But if I uninstall ASP.NET 1.1 and then try to log on using LogonUser Function, it returns true for right credentials (with ASP.NET 1.0) . Also If I use the same code (with ASP.NET 1.1) on Windows XP machine or Windows 2003 Server machine, it works fine. It’s just giving me problem on Windows 2000 Professional with ASP.NET 1.1. For testing, I also changed the machine.config file and set the “username” as “SYSTEM” but the problem persists.

    Can any one tell me the reason for this and the workaround for this

    Thanks
    Rupreet Singh
    Rupreet Singh Guest

  2. Similar Questions and Discussions

    1. authenticating users using their windows login with cf 4and windows server 2000
      Does anyone know of a way to authenticate users using cfauthenticate and security context using coldfusion 4 running on a windows server 2000...
    2. windows Xp logon
      My windows logon username was 'edwardsg" and the password was "Password01". On the third incorrect logon, it locked me out of the computer. ...
    3. CDO for Windows 2000 vs CDO for Exchange 2000
      How can I force SmtpMail class to use CDO for Windows 2000 instead of Exchange 2000. We do not use Exchange at all. I want to do this because I...
    4. [PHP] Using PHP with windows logon
      I think if php runs under IIS and IIS is set up to do so, the variable (phpinfo() will tell you its name) is set. I don't know much more. Brenton...
    5. Windows XP cannot logon to Windows 2000 domain
      if the xp is logging on the domain, you shouldn't have this issue. since the "Windows XP Pro machine logging on a secure workgroup", it sounds like...
  3. #2

    Default RE: Logon API on Windows 2000 with ASP.NET 1.1

    It's due to how to use LogonUser correctly. The API needs "Act as part of operating system" privilege on W2K, but not on XP and Win2003. This explains why you succeed on the two later OSs. For the other behavior, ASP.NET work process is tightened under 1.1 so that it no long runs under the System account. The new ASPNET account doesn't have the privilege, so LogonUser will fail.

    To solve you problem, if you have to call LogonUser, configure ASP.NET with an account that has the privilege, or run it with an account that can do what you are trying to do with the LogonUser account. Delegation can also be explored. There are many articles on how to set up ASP.NET.
    jzhu Guest

  4. #3

    Default RE: Logon API on Windows 2000 with ASP.NET 1.1

    Hi!
    Thanks for your reply
    I have already tried with that. I had given ASPNET account high privilege and also added it to "act as part of Operating System", but i still not able to log on. I also tried with setting username="DomainName/DomainAdminUsername" password="DomainAdminPassword" in machine.config , but still i could not log on. Also i gave permission to IUser and IWAM User high previlige ..but all in vain.

    Any more pointers on it would be appreciated.

    Thanks in Advance

    Rupreet Sing


    Rupreet Singh Guest

  5. #4

    Default Re: Logon API on Windows 2000 with ASP.NET 1.1

    Perhaps is the logon type you are using. If you show the code that has this
    problem it might help.

    --
    Hernan de Lahitte
    Lagash Systems S.A.
    [url]http://weblogs.asp.net/hernandl[/url]


    This posting is provided "AS IS" with no warranties, and confers no rights.

    "Rupreet Singh" <anonymous@discussions.microsoft.com> wrote in message
    news:620AE47A-1502-476B-BC8C-93EFA178DFBC@microsoft.com...
    > Hi!
    > Thanks for your reply.
    > I have already tried with that. I had given ASPNET account high
    privilege and also added it to "act as part of Operating System", but i
    still not able to log on. I also tried with setting
    username="DomainName/DomainAdminUsername" password="DomainAdminPassword" in
    machine.config , but still i could not log on. Also i gave permission to
    IUser and IWAM User high previlige ..but all in vain.
    >
    > Any more pointers on it would be appreciated.
    >
    > Thanks in Advance.
    >
    > Rupreet Singh
    >
    >

    Hernan de Lahitte Guest

  6. #5

    Default Re: Logon API on Windows 2000 with ASP.NET 1.1

    Hi
    Here is the code i used for logging.

    [DllImport(@"C:\Windows\System32\ADVAPI32.DLL",SetL astError=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_LOG ON_NETWORK,LOGON32_PROVIDER_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

    Thank
    Rupreet Sing

    Rupreet Singh Guest

  7. #6

    Default Re: Logon API on Windows 2000 with ASP.NET 1.1

    You really really should be using the canonical example for calling
    LogonUser via P/Invoke that MS published in the Framework SDK reference:

    [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemSecurityPrincipalWindowsImpersonationCo ntextClassTopic.asp?frame=true[/url]

    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",SetL astError=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_LOG ON_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
    >

    Joe Kaplan \(MVP - ADSI\) Guest

  8. #7

    Default Re: Logon API on Windows 2000 with ASP.NET 1.1

    Try to find more info
    1. Right before you call LogonUser, call User.Identity.Name to dump the curent user to see what's the account you are under
    2. Right after you get a false, call Marshal.GetLastWin32Error() to get the error code


    jzhu 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