Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Windows Authentication for beginners...

Status
Not open for further replies.

checkai

Programmer
Jan 17, 2003
1,629
US
I want to be able to read which AD Groups the connected user is in. Here's what I have so far, but it seems as though, only the users local groups are being read; not those in AD..

Code:
Dim userName As String
        Dim wp As System.Security.Principal.WindowsPrincipal = New System.Security.Principal.WindowsPrincipal(System.Security.Principal.WindowsIdentity.GetCurrent())
        Me.lbluser.Text = wp.Identity.Name
        Me.TextBox1.Text = "IT Developers: " & wp.IsInRole("VirchowKrause\ITDevelopers") & vbCrLf & "Administrators: " & wp.IsInRole("BUILTIN\Administrators")

The Administrators = True, but the ITDevelopers role which is in AD, shows as False.

Any suggestions or tips for doing this would be appreciated

dlc
 
The way I handle this is I create keys in my Web.config file for the domain groups I want to check for first.

Code:
<appSettings>
  <add key="Role" value="DOMAIN\GroupName" />
</appSettings>

Then when I want to check for that role I do the following:
Code:
If User.IsInRole(ConfigurationSettings.AppSettings("Role")) Then
  'Execute Some Code here
End If

HTH
Eva
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top