CurrentPrincipal, WindowsPrincipal

Discussion in 'ASP .Net' started by Mark, Jan 12, 2004.

  1. Mark

    Mark Guest

    Hello Friends
    Please check following Code

    Dim x As System.Security.Principal.WindowsPrincipal

    x = System.Threading.Thread.CurrentPrincipal
    Response.Write
    (System.Security.Principal.WindowsIdentity.GetCurrent.Authe
    nticationType & "<BR>")
    Response.Write
    (System.Security.Principal.WindowsIdentity.GetCurrent.Name
    & "<BR>")
    Response.Write(x.IsInRole
    (System.Security.Principal.WindowsBuiltInRole.Administrator
    ) & "<BR>")
    Response.Write(x.IsInRole
    (System.Security.Principal.WindowsBuiltInRole.User)
    & "<BR>")
    Response.Write(x.IsInRole("MyDomain\MyGroup")
    & "<BR>")

    Response.Write("<BR>----<BR>")

    x = New System.Security.Principal.WindowsPrincipal
    (System.Security.Principal.WindowsIdentity.GetCurrent)
    Response.Write
    (System.Security.Principal.WindowsIdentity.GetCurrent.Authe
    nticationType & "<BR>")
    Response.Write
    (System.Security.Principal.WindowsIdentity.GetCurrent.Name
    & "<BR>")
    Response.Write(x.IsInRole
    (System.Security.Principal.WindowsBuiltInRole.Administrator
    ) & "<BR>")
    Response.Write(x.IsInRole
    (System.Security.Principal.WindowsBuiltInRole.User)
    & "<BR>")
    Response.Write(x.IsInRole("MyDomain\MyGroup")
    & "<BR>")

    The result using Basic Windows Authentication, and looged
    in with a valid user name "validusername".


    NTLM
    FUSION-PUNE\validusername
    True
    True
    False

    ----
    NTLM
    FUSION-PUNE\validusername
    True
    True
    False

    The result when "Anonymous Access" set in IIS.

    NTLM
    FTPUNE0025\IUSR_FTPUNE0025
    False
    False**********
    False

    ----
    NTLM
    FTPUNE0025\IUSR_FTPUNE0025
    False
    True****
    False

    **** Why there is a difference for same user.

    Regards
    Mark
    Mark, Jan 12, 2004
    #1
    1. Advertising

  2. Mark

    qvo178

    Joined:
    Aug 28, 2008
    Messages:
    19
    Thanks this has help me.
    qvo178, Feb 23, 2010
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kevin Burton

    WindowsPrincipal and WindowsIdentity.

    Kevin Burton, Jan 7, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    7,365
    bruce barker
    Jan 8, 2004
  2. Peter Moberg

    Role empty in WindowsPrincipal

    Peter Moberg, Jul 25, 2003, in forum: ASP .Net Security
    Replies:
    0
    Views:
    133
    Peter Moberg
    Jul 25, 2003
  3. Mark

    CurrentPrincipal, WindowsPrincipal

    Mark, Jan 12, 2004, in forum: ASP .Net Security
    Replies:
    1
    Views:
    165
    zeldadog
    Jan 12, 2004
  4. naijacoder naijacoder

    WindowsPrincipal.IsInRole() problem with non-builtin roles

    naijacoder naijacoder, Aug 30, 2004, in forum: ASP .Net Security
    Replies:
    4
    Views:
    247
    Joe Kaplan \(MVP - ADSI\)
    Sep 2, 2004
  5. Vic

    isinrole reverts to windowsprincipal?

    Vic, Nov 26, 2004, in forum: ASP .Net Security
    Replies:
    0
    Views:
    143
Loading...

Share This Page