isinrole reverts to windowsprincipal?

From: Vic (vrubba_at_hotmail.com)
Date: 11/26/04


Date: 26 Nov 2004 13:14:13 -0800

I'm trying to assign all roles (AD and custom pulled from SQL Table)
to users when they login to the app using Windows Authentication. The
code works fine for local users but fails for AD users if the IIS
server is a member server of the domain. It does seem to work however
if the IIS server is a domain controller (not an option,
unfortunately).

In the global.asax under the WindowsAuthentication_OnAuthenticate
event I grab all the WindowsPrincipal roles using reflection
(...GetMethod("GetRoles"...), grab all the custom roles from the db,
create a GenericPrincipal and assign them. I then assign the
GenericPrincipal to the HttpContext.Current.User.

On my first default.aspx page, I use reflection again to parse out the
roles of my HttpContext.User (...GetField("m_roles"...) and it returns
successfully all the roles I have assigned in the global.asax. The
HttpContext.Current.User.IsInRole("...") however consistently returns
false when checking for any of the SQL roles added, yet works for the
rest.

It seems that in the cases where it fails (windows authentication
against AD using AD account on an IIS member server), the IsInRole
seems to query exclusively against the ORIGINAL WindowsPrincipal,
regardless of what I attempt in my code. I have tried creating my own
custom principal class, played with impersonate options, tried using
Thread instead of HttpContext, etc... to no avail.

Anyone able to shed some light on why this is happening? And
hopefully provide me with a solution?

Victor



Relevant Pages

  • Re: Q: Named pipes and Windows (integrated) authentication
    ... >By the way, if you don't have SQL Enterprise Manager, there's an MSDE ... >>>his windows authentication to connect to the server. ... >>>Creating databases is only acomplished after you've already connected. ...
    (microsoft.public.sqlserver.connect)
  • RE: MELL and SQL
    ... At this point I'm logged in as admin and since ... have the necessary permissions for the installation. ... > Most third party apps don't use Windows Authentication, they use SQL ...
    (microsoft.public.windows.server.sbs)
  • Re: SQL Server Authentication
    ... I'm sorry to hear you are having some troubles with SQL authentication. ... can I would love to persuade you to use Windows authentication if at all ... > With VSTO using Visual Studio 2005, has anyone manage to use SQL Server ...
    (microsoft.public.vsnet.vstools.office)
  • Re: SQL Server uses Windows authentication
    ... > With Windows Authentication you do not put any credentials in the ... The connection uses the credentials of whatever ... >> 1 remote web server to connect to an SQL db on a completely different ...
    (microsoft.public.inetserver.asp.db)
  • Re: Login failed for ServerGuest
    ... SQL Server clients are authenticated as guests if Simple ... >| I have noticed that when I try to log in using Windows Authentication ... >|> You can enable the guest account but that's a security risk ...
    (microsoft.public.sqlserver.connect)