Re: How do I check for domain group membership?

From: Dominick Baier [DevelopMentor] (dbaier_at_pleasepleasenospamdevelop.com)
Date: 09/29/05


Date: Thu, 29 Sep 2005 12:23:25 -0700

Hello Byron,

you have to use the fully qualified group name - which is DOMAIN\GroupName

---------------------------------------
Dominick Baier - DevelopMentor
http://www.leastprivilege.com

> I have a WinForm app that will run on XP boxes in a Win2003 AD domain
> named "GTI.int". I have several Universal security groups named
> "ILF_x", one of which is "ILF_Installer" and I have made myself a
> member of that group for development. There are arrays of security
> group names associated with menu items along with other things that
> should be enabled or disabled based on security group membership,
> though my example code only uses the one group "ILF_Installer" for
> testing. I need a method that will iterate the array of acceptable
> security group names and return true if the current user is a member
> of at least one group, or false otherwise.
>
> I have tried the below listed code without success to test for my
> membership in the "ILF_Installer" group.
>
> As always, any help would be greatly appreciated.
>
> --------------------- SNIP
> --------------------------------------------------------------
> AppDomain myDomain = Thread.GetDomain();
> myDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
> WindowsPrincipal prin = (WindowsPrincipal)Thread.CurrentPrincipal;
>
> Console.WriteLine("Principle:" + prin.Identity.Name);
>
> // The preceding line correctly displays GTI\MyUserName
>
> if ( prin.IsInRole("ILF_Installer") )
> Console.WriteLine("ILF_Installer");
> // The preceding block does NOT display "ILF_Installer" as desired.
> -------------------------------- SNIP
> ------------------------------------------
>



Relevant Pages

  • Re: How do I check for domain group membership?
    ... WindowsIdentity i = p.Identity; ... > I know I'm a member of that domain> universal security group. ... There are arrays of security>>> group names ...
    (microsoft.public.dotnet.security)
  • Re: drop down lists and drill down
    ... "?myvalue" now try to open the view, ... criteria being the selection on the previous dropdown. ... You can go with arrays too, but you need to requerythe dropdowns ... any item is a member of ...
    (microsoft.public.fox.helpwanted)
  • Re: drop down lists and drill down
    ... "?myvalue" now try to open the view, ... criteria being the selection on the previous dropdown. ... You can go with arrays too, but you need to requerythe dropdowns ... any item is a member of ...
    (microsoft.public.fox.helpwanted)
  • Re: drop down lists and drill down
    ... criteria being the selection on the previous dropdown. ... You can go with arrays too, but you need to requerythe dropdowns ... any item is a member ... I need 4 pull downs which will be popultaed with the ...
    (microsoft.public.fox.helpwanted)
  • Re: drop down lists and drill down
    ... how the help system explains how you USE parameterised queries. ... criteria being the selection on the previous dropdown. ... You can go with arrays too, but you need to requerythe dropdowns ... any item is a member of ...
    (microsoft.public.fox.helpwanted)