Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Security > Checking if User is in Role

Reply
Thread Tools

Checking if User is in Role

 
 
mc
Guest
Posts: n/a
 
      04-26-2007
I would like to check if a user is currently a member of a Local Group on the server. I am able to
do the test for the current user and all is ok, however I would like to be able to take a list of
users from a table in the database and check if the user is in the specified group. is it possible
to take a username (as a string) and create an instance of IPricipal for that user? or achive by any
other method?

Regards


MC
 
Reply With Quote
 
 
 
 
Alexey Smirnov
Guest
Posts: n/a
 
      04-26-2007

"mc" <(E-Mail Removed)> wrote in message
news:4630d7e6$(E-Mail Removed)...
>I would like to check if a user is currently a member of a Local Group on
>the server. I am able to do the test for the current user and all is ok,
>however I would like to be able to take a list of users from a table in the
>database and check if the user is in the specified group. is it possible to
>take a username (as a string) and create an instance of IPricipal for that
>user? or achive by any other method?
>


The following code returned true if UserName is a member of a Power Users
group.
DirectoryEntry entryRoot = new DirectoryEntry("WinNT://" +
Environment.MachineName + ",computer",
Environment.MachineName +"\\" + SuperUserName, SuperUserPassword,
System.DirectoryServices.AuthenticationTypes.Reado nlyServer);
DirectoryEntry userEntry = entryRoot.Children.Find(UserName, "user");
DirectoryEntry objGroup = entryRoot.Children.Find("Power Users", "group");
bool isMember = (bool)objGroup.Invoke("IsMember", new object[] {
userEntry.Path.ToString() });

SuperUserName is a local user


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
user.roles -- How do you list the role names of the user? Bob Sanders Ruby 6 11-10-2007 01:40 AM
AzMan Role Based Security vs. ASP.NET Role Based Security Kursat ASP .Net Security 1 05-07-2007 01:33 PM
Checking if User is in Role mc ASP .Net 6 05-02-2007 08:50 AM
Role-Based Security: ACLs and Role Hierarchies Liet Kynes ASP .Net 0 11-26-2003 08:08 AM
Role-based security: Access the role of current user Jesper Stocholm ASP .Net 2 08-23-2003 06:59 PM



Advertisments