CurrentPrincipal, WindowsPrincipal

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

  1. Mark

    Mark Guest

    Hello Friend
    Please check following Cod

    Dim x As System.Security.Principal.WindowsPrincipa

    x = System.Threading.Thread.CurrentPrincipa
    Response.Writ
    (System.Security.Principal.WindowsIdentity.GetCurrent.Auth
    nticationType & "<BR>"
    Response.Writ
    (System.Security.Principal.WindowsIdentity.GetCurrent.Name
    & "<BR>"
    Response.Write(x.IsInRol
    (System.Security.Principal.WindowsBuiltInRole.Administrato
    ) & "<BR>"
    Response.Write(x.IsInRol
    (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.AuthenticationType & "<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"

    NTL
    FUSION-PUNE\validusernam
    Tru
    Tru
    Fals

    ---
    NTL
    FUSION-PUNE\validusernam
    Tru
    Tru
    Fals

    The result when "Anonymous Access" set in IIS

    NTL
    FTPUNE0025\IUSR_FTPUNE002
    Fals
    False***
    Fals

    ---
    NTL
    FTPUNE0025\IUSR_FTPUNE002
    Fals
    True***
    Fals

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

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

  2. Mark

    zeldadog Guest


    >-----Original Message-----
    >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
    >.
    >I must go to work now-be back later-zeldadog
     
    zeldadog, Jan 12, 2004
    #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,406
    bruce barker
    Jan 8, 2004
  2. Mark
    Replies:
    1
    Views:
    3,208
    qvo178
    Feb 23, 2010
  3. Peter Moberg

    Role empty in WindowsPrincipal

    Peter Moberg, Jul 25, 2003, in forum: ASP .Net Security
    Replies:
    0
    Views:
    147
    Peter Moberg
    Jul 25, 2003
  4. naijacoder naijacoder

    WindowsPrincipal.IsInRole() problem with non-builtin roles

    naijacoder naijacoder, Aug 30, 2004, in forum: ASP .Net Security
    Replies:
    4
    Views:
    258
    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:
    156
Loading...

Share This Page