Click to See Complete Forum and Search --> : Role based security


Anthony Jones
11-20-2002, 11:28 AM
People,

I'm just trying to absorbe .NETs role-based security services but seem to
have a brick wall before I have even begun.

My basic question is how are Roles assigned to a Windows user so that when
using Windows Principal Policy the call
WindowsPrinicipal.IsInRole("SomeRoleName") will return an appropriate value?
I've tried using the name of a Group which the windows user is a member but
that didn't work.

There is obviously some basic piece of knowledge that I am missing, 'any
help here will be hot'?

Anthony.

Paul Clement
11-20-2002, 02:34 PM
On Wed, 20 Nov 2002 16:28:30 -0000, "Anthony Jones" <Ant@yadayadayada.com> wrote:

¤ People,
¤
¤ I'm just trying to absorbe .NETs role-based security services but seem to
¤ have a brick wall before I have even begun.
¤
¤ My basic question is how are Roles assigned to a Windows user so that when
¤ using Windows Principal Policy the call
¤ WindowsPrinicipal.IsInRole("SomeRoleName") will return an appropriate value?
¤ I've tried using the name of a Group which the windows user is a member but
¤ that didn't work.
¤
¤ There is obviously some basic piece of knowledge that I am missing, 'any
¤ help here will be hot'?

I don't have much code to look at here, but you might want to check the following:

HOW TO: Check the Windows Identity in a Client Application in Windows .NET Framework
http://support.microsoft.com/default.aspx?scid=kb;en-us;301256


Paul ~~~ pclement@ameritech.net
Microsoft MVP (Visual Basic)

John Butler
11-20-2002, 06:44 PM
The MSDN site has a large but comprehensive security document (600 pages) on
implementing security in ASP.NET. I don't have the link, but have a search
or perhaps someone else could post it.

regards
John Butler

John Butler
11-20-2002, 06:49 PM
Actually, the link is on the front page. I recommend getting it...it'll
answer your questions..

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/ht
ml/secnetlpMSDN.asp

Anthony Jones
11-20-2002, 07:06 PM
Thanks Paul.

I am currently been going through the MS Press book for Exams 70-306/316 and
frankly the example code snippets leave much to be desired. A good many of
them either don't work at all, are misleading and in some cases over
complicated.

What was missing from my attempts were the domain prefixes. The following
works:

AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal)

Dim myPrincipal As IPrincipal
Dim myIdentity As IIdentity

myPrincipal = Threading.Thread.CurrentPrincipal
myIdentity = myPrincipal.Identity

Debug.WriteLine(myIdentity.Name)
Debug.WriteLine(myPrincipal.IsInRole("DEV\Nuesoft"))

Both the book and the link you posted over complicate things with
unneccessary casts and in the case of the linked article fails to cast when
narrowing.

Anthony.