Ask a Question related to ASP.NET Security, Design and Development.

  1. #1

    Default Getting AD Groups

    Hi Gurus,

    I seek you expert advice on the following scenario:-

    Environment: Windows 2003, IIS6, Windows Integrated Authentication, .Net
    Framework 1.1, ASP.Net, C#
    Based on the Integrated Windows Authentication, I'm trying to get the AD
    groups where the user's belong to from my ASP.Net page.

    Any pointers, articles, links or samples are appreciated.

    Thanks in advance.


    Han



    Guest

  2. Similar Questions and Discussions

    1. Permission groups
      We cannot connect to our site as we have no permsion groups showing. Does anyone know how we recreate the administrator permission group?
    2. Google groups
      Hi Why am I not able to finde this newsgroup in Google Groups Henning
    3. Tip from NANAU for R.P.* groups
      Aministrator wrote: been that recent troll activity fake This that be a
    4. I'm still confused by the difference between Global Groups and Domain Local Groups
      Experts, I'm still confused by the difference between Global Groups and Domain Local Groups. I mean, they seem to me to accomplish the very same...
    5. OT about CSS (other groups wont help)
      hello all. this is some CSS code that I have and it works great with links. however, is it possible to achieve the same effect for images, buttons,...
  3. #2

    Default Re: Getting AD Groups

    Actually, even better is just to query the user's group membership via the
    IPrincipal object in Context.User. From any web page you can do:

    Context.User.IsInRole("mydomain\\mygroup");

    With Windows Integrated Auth, the runtime uses the token created by IIS
    during login to create a WindowsPrincipal object that will contain all of
    the user's security group memberships. You just specify them in
    domain\groupname format and you are all set.

    Querying groups via S.DS works too, but I wouldn't recommend it if the
    user's login token is already built. If you needed to query group
    membership for a different user, then an AD lookup might be needed. Let me
    know if you need the actual S.DS code to do that (it can be a bit icky).

    Joe K.

    "David Coe, MCP" <anonymous@discussions.microsoft.com> wrote in message
    news:637F08F5-FA55-45E6-A6EB-4EFB656F15E7@microsoft.com...
    > Check out classes inside of the System.DirectoryServices namespace. It's
    pretty simple from there.


    Joe Kaplan \(MVP - ADSI\) Guest

  4. #3

    Default Re: Getting AD Groups

    Since you are using Windows Integrated Security and all the other parts
    that make life wonderful I would agree with Joe Kaplan and look into the
    token that is available on every page you request. At least it is
    available on every page if anonymous authentication is also off or
    web.config only allows authenticated users, or a some acl set somewhere
    forces the authentication. But anyways on to the references...

    Dan Appleman wrote a nice E-Book on Amazon that covers ways to use
    reflection to call private members of the framework to get at a Tokens
    Groups. It is really cool but not a secure practice. With the 1.1
    framework you can run the web application in partial trusted modes that
    disallow reflection, which is good. Here is the link called Hijacking
    ..Net Vol 1: Role Based Security [DOWNLOAD: PDF]
    [url]http://www.amazon.com/exec/obidos/tg/detail/-/B00009AQ5P/ref=mt_dl_dtl_eb/104-6955238-2682323?v=glance&s=ebooks[/url]


    Another way to get the user groups from a token is through PInvoke of
    the Win32 APIs. Keith Brown wrote a COM component to that we as c#
    developers can call through COM Interop rather than the laborious
    PInvoke process that it would take in C#. Look at the code and you will
    see. Here is the link
    [url]http://www.pluralsight.com/keith/security/code/tokdumpsrv.zip[/url]
    Their site is brand new so I actually had to infer this link. Look in
    the bin directory and register the dll. If you need some help getting
    it to work before they have the site running let me know. Or see the
    next item.

    I have worked on a HttpModule that hosts the tokdumpsrv.dll. The module
    is setup of to accept providers. I wrote a sample provider that
    contains the HttpModule. It is all in a solution with a sample web app
    just to demo how it could work when I am done. Basically there is just
    a default.aspx page that does nothing more than show you who the user is
    requesting the page. Add the querystring (?DCtrace=true) to the end of
    the url and out dumps the full token dump of the thread token and the
    process token. My intension for this are to be able to trouble shoot
    developer and production web servers experiencing authentication and
    authorization craziness...
    Check out a screen dump and down load a zip of the solution here in my
    blog.
    [[url]http://www.deploymentcentric.com/Blogs/joe/PermaLink.aspx?guid=5c549203-fa43-434d-84a0-a445a870cdbb][/url]
    Send me your questions and maybe I can get back to working on it.


    I am hoping that the 2.0 framework will have some of these features
    built in. IsInRole is nice but you have to know the roles ahead of
    time. That is great for standard role based security.











    [email]hanafiahh@hotmail.com[/email] wrote:
    > Hi Gurus,
    >
    > I seek you expert advice on the following scenario:-
    >
    > Environment: Windows 2003, IIS6, Windows Integrated Authentication, .Net
    > Framework 1.1, ASP.Net, C#
    > Based on the Integrated Windows Authentication, I'm trying to get the AD
    > groups where the user's belong to from my ASP.Net page.
    >
    > Any pointers, articles, links or samples are appreciated.
    >
    > Thanks in advance.
    >
    >
    > Han
    >
    >
    >
    Joseph E Shook [MVP - ADSI] Guest

  5. #4

    Default RE: Getting AD Groups

    One option is to use DataMarvel's wrapper for Win32 APIs
    [url]http://www.DataMarvel.co[/url]
    Using its NAccessToken wrapper with your current "WindowsIdentity.Token", you can call "Groups" property that returns all groups and its attributes, or simply call "UserGroups" that returns all the "regular" groups in the form of "domain\user" format ("regular" means it ignores the "Logon SID" and all the restrictive groups). Its try version has a sample solution that shows how to call them.
    jzhu Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139