Hi,
I tried <domain>\Gamers but it does not work
Here is my code
Class File
---------------------------------------------------------------
AppDomain.CurrentDomain.SetPrincipalPolicy(Princip alPolicy.WindowsPrincipal);
WindowsPrincipal prin = (WindowsPrincipal)Thread.CurrentPrincipal;
WindowsIdentity identity = (WindowsIdentity)prin.Identity;
----------------------------------------------------------------
Web config
-------------------------------------------------------------
<authentication mode="Windows">
</authentication>
<identity impersonate="true"/>
-------------------------------------------------------------
When I try to get the role thru this code below which i found on the web
Code--------------------------------------------------------------------------
public static string GetUserRoles(WindowsPrincipal winPrincipal)
{
string userRoles = "";
WindowsIdentity identity = winPrincipal.Identity as WindowsIdentity;
if (identity != null)
{
Type t = identity.GetType();
string[] roles = (string[]) t.InvokeMember("GetRoles",
BindingFlags.Instance | BindingFlags.NonPublic |
BindingFlags.InvokeMethod,null,identity,null);
if (roles != null)
{
foreach (string role in roles)
{
if(userRoles != "")
{
userRoles += ",";
}
userRoles += role;
}
}
}
return userRoles;
}
-----------------------------------------------------------------
I got the results as following
<domainname>\Domain Users,Everyone,BUILTIN\Administrators,BUILTIN\User s,NT
AUTHORITY\INTERACTIVE,NT AUTHORITY\Authenticated Users,,LOCAL,
It does not have <domainname\Gamers>
However by using LDAP i am able to get CN=Gamers
Did I configure something wrong?.Thanks
Joey
"Dominick Baier [DevelopMentor]" <>
wrote in message news: om...
> Hello Joey,
>
> WindowsPrincipal.IsInRole expects fully qualified group names - these are
> AUTHORITY\GROUP
>
> e.g. DOMAIN\Gamers for domain accounts
>
> or MyMachine\Gamers for local accounts
>
>
> ---------------------------------------
> Dominick Baier - DevelopMentor
> http://www.leastprivilege.com
>
>> Hi,
>>
>> I am using windows authentication on my ASP.Net application. With the
>> WindowsPrincipal I can authenticate myself against groups such as
>>
>> BUILTIN\Users
>>
>> I am assuming that this group is supplied by the active directory when
>> i log into the domain using my pc.
>>
>> The problem now is I have added another custom group - Gamers. I tried
>> authentication using IsInRole("Gamers") but this give me false. How do
>> I do it with Windows Authentication for this new group?
>>
>> I have another way of doing this but that is using ldap
>> authentication, but I am trying to understand and make the Windows
>> Authentication work. Please help. Thanks
>>
>> Joey
>>
>
>