How to use WindowsPrincipal properly??

From: Kevin Yu (kyu@nrcan.gc.ca)
Date: 10/29/02


From: "Kevin Yu" <kyu@nrcan.gc.ca>
Date: Tue, 29 Oct 2002 10:17:44 -0700


I am working on this intranet app here need proper authentication for users
and redirect them according
to their roles. I set app on IIS to use windows integrated authentication
and in my code, I check when user
login and get their identity, now I run into some minor problem, seems like
the following statement return
different result:

user.IsInRole(WindowsBuiltInRole.Administrator) this return false

and this

user.IsInRole("BUILTIN\Administrators") this return true

for the same user? what is the difference?

another question is how can I make sure user enter a proper domain in the
popup login?
say if the user dont enter the domain/computername that supposed to
authenticate him/her,
then I need to check domain in my code as well? since the
user.Indentity.Name will return
DOMAIN\username, then in code need to parse the domain and username and
validate both
of them, I saw some other code that use Impersonation as the following:

<DllImport("C:\\WINNT\\System32\\advapi32.dll")> _
   Public Shared Function LogonUser(lpszUsername As String, lpszDomain As
String, lpszPassword As String, _
            dwLogonType As Integer, dwLogonProvider As Integer, ByRef
phToken As Integer) As Boolean
   End Function

seems like with Impersonation, there are lots more code needed. can anyone
clarify what the differences are between
the two?

thanks



Relevant Pages

  • ASP.NET Forms Authentication Best Practices
    ... ASP.NET Forms Authentication Best Practices ... What happens if your user database is compromised? ... Listing One, where you want to use login.aspx to log users in. ... string FirstName ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Repeater paging problem
    ... First about your "authentication". ... The way things should be done: Create checkboxes inside ... your comma separated string property will already be ready when your ... Doing it this way, you won't need no Session variable, no iteration thru ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)
  • Re: How to get user id guid
    ... string PrintName ... int nSize = translatedName.Capacity; ... My web site is using Integrated Windows authentication with Digest ...
    (microsoft.public.dotnet.security)
  • RE: Event ID: 6482 after installation
    ... Setting authentication method to 'NTLM' for IIS web site 'Office Server ... CspParameters parameters, Boolean randomKeyContainer, Int32 dwKeySize, ... AuthenticationMethods authenticationMethods, String[] ...
    (microsoft.public.sharepoint.portalserver)
  • Re: The pest of Impersonation
    ... On 24 Sep, 18:56, "Joe Kaplan" ... What type of authentication is used on the ASP.NET site? ... delegation to get the credentials to flow from the browser to your web site ... string CloseText = o).closecomment; ...
    (microsoft.public.dotnet.framework.aspnet.security)