Ask a Question related to ASP.NET Security, Design and Development.
-
James McFarland #1
FormsAuthentication Roles Problem
I want to use FormsAuthentication and allow access based on role.
I have a /Admin directory on the web app, and want to allow role "admin",
but deny all other users.
/Web.config:
<authorization>
<allow users="*" /> <!-- Allow all users -->
</authorization>
/Admin/Web.config:
<authorization>
<allow roles="admin"/>
<deny users="*"/>
</authorization>
This setup prevents all users from accessing pages in the /Admin folder,
even users whose IPrincipal.IsInRole("admin") implementation returns true.
If I change /Amdin/Web.config to the below, it allows the "admin@mysite.com"
user in:
<authorization>
<allow users="admin@mysite.com" roles="admin"/>
<deny users="*"/>
</authorization>
Anyone ever seen this problem or have any idea what I am doing wrong?
All examples I have seen appear to use the <allow roles="admin"/> approach.
Thanks,
-james
--
James McFarland :: SunPorch Structures Inc.
James McFarland Guest
-
DESPERATE: FormsAuthentication Problem
I am having a very perplexing problem with setting the user's roles. I have tried to figure this out for 2 days now. When the user logs in to the... -
FormsAuthentication.SignOut() problem
Hi All, (thanks in advance for your time) I have a standard login.aspx page (UserName\Password). When the user successully sign in they are... -
Problem with FormsAuthentication.RedirectFromLoginPage
I am having problem with redirection from http-https-http First an http application gets redirected to https application for authentication... -
FormsAuthentication client-side problem
I'm using FormsAuthentication to secure access to a web site. The authentication process works correctly initially. The pages on the site have a... -
FormsAuthentication.Encrypt problem
Hi, I have a strange problem. I get NULL reference out of Encrypt function. FormsAuthenticationTicket ticket = new... -
[MSFT] #2
RE: FormsAuthentication Roles Problem
Hello James,
I think you should put the domain/machine name before "Admins". Also,
please pay attention to that these names (including the group name) are
case sensitive.
Hope this help,
Luke
[MSFT] Guest
-
James McFarland #3
RE: FormsAuthentication Roles Problem
"[MSFT]" wrote:
Luke:> Hello James,
>
> I think you should put the domain/machine name before "Admins". Also,
> please pay attention to that these names (including the group name) are
> case sensitive.
>
> Hope this help,
>
> Luke
>
>
>
I checked the case, and that all matches.
Just to furhter clarify, I am not using AD or Windows Authentication, so the
domain name/machine name are not relevant in my case.
Does that make sense?
Thanks,
-james
James McFarland Guest
-
[MSFT] #4
RE: FormsAuthentication Roles Problem
Since you use Form authentication, can you explain more about how you
implement IPrincipal.IsInRole and Application_AuthenticateRequest?
Normally, we need grant roles in Application_AuthenticateRequest like:
Sub Application_AuthenticateRequest(ByVal sender As Object, ByVal e As
EventArgs)
if (not(HttpContext.Current.User is Nothing)) then
if HttpContext.Current.User.Identity.AuthenticationTy pe = "Forms" then
Dim id as System.Web.Security.FormsIdentity
id = HttpContext.Current.User.Identity
Dim MyRoles(2) As String
MyRoles(0) = "Manager"
MyRoles(1) = "Admin"
HttpContext.Current.User = new
System.Security.Principal.GenericPrincipal(id,MyRo les)
End if
End if
End sub
Luke
[MSFT] Guest
-
Patrick.O.Ige #5
RE: FormsAuthentication Roles Problem
I think try MSFT advice first and see....
And make sure u have Anonymous Access when using Forms Auth!
With Web.Config its case sensitive so be careful...
Enjoy!
Patrick
"[MSFT]" wrote:
> Since you use Form authentication, can you explain more about how you
> implement IPrincipal.IsInRole and Application_AuthenticateRequest?
> Normally, we need grant roles in Application_AuthenticateRequest like:
>
> Sub Application_AuthenticateRequest(ByVal sender As Object, ByVal e As
> EventArgs)
> if (not(HttpContext.Current.User is Nothing)) then
> if HttpContext.Current.User.Identity.AuthenticationTy pe = "Forms" then
> Dim id as System.Web.Security.FormsIdentity
> id = HttpContext.Current.User.Identity
>
> Dim MyRoles(2) As String
> MyRoles(0) = "Manager"
> MyRoles(1) = "Admin"
> HttpContext.Current.User = new
> System.Security.Principal.GenericPrincipal(id,MyRo les)
> End if
> End if
> End sub
>
>
> Luke
>
>Patrick.O.Ige Guest



Reply With Quote

