Re: Check group member ship or a user

From: Dominick Baier [DevelopMentor] (dbaier_at_pleasepleasenospamdevelop.com)
Date: 02/23/05

  • Next message: Dominick Baier [DevelopMentor]: "Re: Impersonation using WindowsIdentity( upn ) ctor"
    Date: Wed, 23 Feb 2005 12:45:07 -0800
    
    

    Hello Sameh,

    hmm - try

    AppDomain.Current.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal) at
    the beginning of your App (main)

    then afterwards

    if (Thread.CurrentPrincipal.IsInRole(".."));

    (sorry - only compiled with Omea Reader :)

    does that work??

    dominick

    > Hello Dominick
    > Thanks for your time
    > it's a windows form application using VB .net
    > I do almost the same as you explained below
    > Dim s As New
    > Security.Principal.WindowsPrincipal(System.Security.Principal.WindowsI
    > dentity.GetCurrent)
    > MsgBox(s.Identity.Name)
    > MsgBox(s.IsInRole("machinename\groupname"))
    > and it simply always returns false
    > although, there is a group called "groupname" and the machine is
    > called
    > "machinename"
    > any ideas would be really appricated.
    > Regards
    > Sameh
    > "Dominick Baier [DevelopMentor]"
    > <dbaier@pleasepleasenospamdevelop.com> wrote in message
    > news:eQ$%23do0FFHA.3824@TK2MSFTNGP10.phx.gbl...
    >
    >> sure!
    >>
    >> You have to construct a WindowsPrincipal object for that user.
    >>
    >> What kind of application are we talking about?
    >>
    >> In Console/WinForms apps you get the current logged on user with
    >>
    >> WindowsIdentity id = WindowsIdentity.GetCurrent();
    >>
    >> and then construct a WindowsPrincipal with:
    >>
    >> WindowsPrincipal principal = new WindowsPrincipal(identity);
    >>
    >> after that you can call:
    >>
    >> if (principal.IsInRole(@"DOMAIN\Marketing"))
    >> ...
    >> i did a talk at WinDev about this topic and you can find the slides
    >> and some democode here:
    >> http://www.leastprivilege.com/PermaLink.aspx?guid=14fd81b2-dc23-4670-
    >> bf04-ad16552083f3
    >>
    >> ---
    >> Dominick Baier - DevelopMentor
    >> http://www.leastprivilege.com
    >> nntp://news.microsoft.com/microsoft.public.dotnet.security/
    >> HA.2736@TK2MSFTNGP09.phx.gbl>
    >>
    >> Hello there
    >> Is there a way through dotNet to check if a certain user is a member
    >> of a
    >> specific group?
    >> I use ADSI to get the memberships of the user then compare them to
    >> the
    >> group
    >> I want to check, but this way the user has to be a member of this
    >> group
    >> directly and if he is a member of a group that is a member of that
    >> group
    >> he
    >> will not be considered a member of the group I am checking although
    >> he is
    >> implicitly.
    >> so basically what I need is a method that takes the user name and the
    >> group
    >> name and check if this user is a member both implicitly or
    >> explicitly.
    >> Any ideas?
    >> Regards
    >> Sameh
    >> [microsoft.public.dotnet.security]
    >>


  • Next message: Dominick Baier [DevelopMentor]: "Re: Impersonation using WindowsIdentity( upn ) ctor"

    Relevant Pages

    • Re: Blue File Names
      ... I have passed your information on to our Member and I'm sure his question is ... > Regards. ... > compact old files. ... >> Hello Joe ...
      (microsoft.public.windowsxp.general)
    • Re: Windows XP is my OS
      ... Is it a member of a domain or standalone? ... Regards ... >> Mark Dormer ... >>> When I logon to the computer I keep getting a windows error message. ...
      (microsoft.public.windowsxp.general)
    • Re: Using todays date
      ... Regards ... > Strange strange strange! ... > Jamie Thomson ... >> this member does exist. ...
      (microsoft.public.sqlserver.olap)
    • Re: Avian Flu, BSE and FMD
      ... You will probably be the only member of the ... >> politburo that will be able to pass though some border controls without a ... Regards ...
      (uk.business.agriculture)
    • Re: Is this of any interest to anyone?
      ... >A member of the ATIS engine list spotted this and I thought you guys ... whole bunch of holes and end up with an accurate metal lathe ... I feel that's a tad optimistic as regards the time scale. ...
      (uk.rec.models.engineering)