Ask a Question related to ASP.NET Security, Design and Development.
-
localhost #1
Enum All Roles in a Principal?
I know how to do ..IsInRole() to test if a user is in a particular
role.
How do I enumerate all of the roles currently attached to my principal
instance? WindowsPrincipal or GenericPrincipal.
Thanks.
localhost Guest
-
Web Service w custom Principal
We have a class that Implements IPrincipal (System.Security.Principal.IPrincipal). We have a business logic class library assembly that checks the... -
Custom Principal
Hi, I use Custom Principal and it works well on my PC (Localhost). When I deploy it at my hosting service it fails. I print out... -
Custom Windows Authentication Principal?
Ok here's the situation, I have several intranet applications at this company that use windows authentication. Now when people open the... -
Setting Principal for HttpWorkerRequest
re: http://www.dotnet247.com/247reference/msgs/31/159270.aspx (neither my news server, nor microsoft's seems to still carry this thread) I am... -
Set Windows Principal
Hi, My current legacy asp/becoming-asp.net application uses IIS Windows Authentication at present. What I need to do is let a user coming from... -
Steven Cheng[MSFT] #2
RE: Enum All Roles in a Principal?
Hi Localhost,
Thanks for posting in the community!
Based on my understanding, you're wanting to manually get the role lists of
a certain IPrinciple object such as WindowsPrincipal or GenreicPrincipal
Based on my research, the dotnet IPrincipal only provide the IsInRole
interface to let use validate a certain role via name. It doesn't provide
the get role lists method. But we can define a custom Principal
class(which has the interface you want) and replace the original Principal
object at runtime. This is what many ones have done. Here is a tech article
on this means:
#Custom roles for WindowsPrincipals in ASP.NET
[url]http://weblogs.asp.net/bhickman/archive/2003/02/07/2018.aspx[/url]
In addition, If you do want to get the roles of a WindowsIdentity, there is
a means using reflection APIs to invoke the private
WindowsIdentity._GetRoles method so that you can see what the actual groups
for the WindowsIdentity are. This
has saved me lots of trouble in the past. VB.NET code sample here:
--------------------------------------------
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim wp As WindowsPrincipal = HttpContext.Current.User
Dim id As WindowsIdentity = wp.Identity
Dim idType As Type
idType = GetType(WindowsIdentity)
Dim result As Object = idType.InvokeMember("_GetRoles", _
BindingFlags.Static Or BindingFlags.InvokeMethod Or
BindingFlags.NonPublic, _
Nothing, id, New Object() {id.Token}, Nothing)
Dim roles() As String = DirectCast(result, String())
Dim i As Integer
For i = 0 To roles.Length - 1
Response.Write("<br>" + roles(i))
Next
End Sub
----------------------------------------------
And since the above means may cause unexpected security issues, we don't
recommend that it be used. :)
Regards,
Steven Cheng
Microsoft Online Support
Get Secure! [url]www.microsoft.com/security[/url]
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Get Preview at ASP.NET whidbey
[url]http://msdn.microsoft.com/asp.net/whidbey/default.aspx[/url]
Steven Cheng[MSFT] Guest
-
Beginner #3
Re: Enum All Roles in a Principal?
You can implement custom IIDentity and IPrincipal and do whatever you want
with it.
[url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/SecNetHT06.asp[/url]
"localhost" <primpilus@cohort.ces> wrote in message
news:hctu30tujssnib50pruo5937c2itkuia3i@4ax.com...>
> I know how to do ..IsInRole() to test if a user is in a particular
> role.
>
> How do I enumerate all of the roles currently attached to my principal
> instance? WindowsPrincipal or GenericPrincipal.
>
> Thanks.
>
Beginner Guest
-
Steven Cheng[MSFT] #4
RE: Enum All Roles in a Principal?
Hi Localhost,
Have you had a chance to try out my suggestion or have you got any further
ideas on this issue? If you need any further assistance ,please feel free
to post here.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure! [url]www.microsoft.com/security[/url]
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Get Preview at ASP.NET whidbey
[url]http://msdn.microsoft.com/asp.net/whidbey/default.aspx[/url]
Steven Cheng[MSFT] Guest



Reply With Quote

