Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post May 31, 2012 08:30 AM by ShaggyDogg
Feb 17, 2012 07:07 PM|LINK
i have a web app that is using active directory for authentication...so instead of setting up my roles in the config file like I normally would, they were set up in the security groups of the active directory. How can I programitcally access these security
groups? i would normally use something like if user.isinroles("admin")...can I still use isInRoles and if so what should I use as my argument, i tried putting in the security group but that didnt seem to work? also would that be the best way of doing it
or is there another way to access the security groups? thanks in advance.
Feb 17, 2012 07:19 PM|LINK
User.IsInRole("role name") works with Active Directory, too. Must have some problem with your role name.
Feb 17, 2012 07:27 PM|LINK
there aren't any roles setup in the AD just security groups...so are you saying that they are one and the same? or do roles need to be set up in AD?
Feb 17, 2012 07:28 PM|LINK
They are one in the same.
Feb 17, 2012 08:27 PM|LINK
ok thanks, once I get a chance ill give it a shot and see what happens...will let you know.
Feb 21, 2012 01:07 PM|LINK
got it to work..thanks.
May 30, 2012 08:43 AM|LINK
I'm having the same issues on the same task as you did, but have not resolved it yet. Would appreciate advise on what is incorrect in the following sample code? The result I get is always that the panel is not visible, even though the authenticated user
is a member of 'Domain\ADGroup'.
If I can at least confirm the code 'should' work, that would be a help.
If HttpContext.Current.User.IsInRole("Domain\ADGroup") Then
Panel1.Visible = True
Label1.Text = "Hello"
Panel1.Visible = False
Label1.Text = "Not working"
<add name="ADService" connectionString="LDAP://Domain.internal"/>
<add name="ApplicationServices" connectionString="Data Source=Server;Initial Catalog=ASPNETDB;Persist Security Info="blah blah" providerName="System.Data.SqlClient"/>
<add name="AspNetActiveDirectoryMembershipProvider" enableSearchMethods="true" type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Version=188.8.131.52, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="ADService" attributeMapUsername="sAMAccountName"/>
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/>
<add name="WindowsProvider" type="System.Web.Security.WindowsTokenRoleProvider"/>
<add connectionStringName="ApplicationServices" applicationName="/" name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider"/>
<add applicationName="/" name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider"/>
Many thanks in advance..
May 31, 2012 08:30 AM|LINK
Don't worry replying - got it working too.
This one line of code (within the system.web element) sorted it instead of what I had
<roleManager enabled="true" defaultProvider="AspNetWindowsTokenRoleProvider" />
Plus this msdn article showing the same syntax was very useful: