Check a user's group

badblueboy

Member
Joined
Mar 12, 2007
Messages
7
Programming Experience
Beginner
hi @ll,

in my application I have a login form where ONLY Domain Admins can log themselves in. My problem is that I don't know how I can check the user's groups if they are in the group "Domain Admins".

VB.NET:
[COLOR=Black][FONT=Courier New][COLOR=Blue][FONT=Courier New]Dim[/FONT][/COLOR] dirSearcher [COLOR=Blue][FONT=Courier New]As[/FONT][/COLOR] [COLOR=Blue][FONT=Courier New]New[/FONT][/COLOR] DirectorySearcher
        [COLOR=Blue][FONT=Courier New]Dim[/FONT][/COLOR] dirResult [COLOR=Blue][FONT=Courier New]As[/FONT][/COLOR] SearchResult

        [COLOR=Blue][FONT=Courier New]Try[/FONT][/COLOR]
 dirSearcher [COLOR=Red][FONT=Courier New]=[/FONT][/COLOR] [COLOR=Blue][FONT=Courier New]New[/FONT][/COLOR] DirectorySearcher([COLOR=Blue][FONT=Courier New]New[/FONT][/COLOR] DirectoryEntry(mstrLoginADSConnectionString, mstrLoginUserID, mstrLoginKennwort))

            dirSearcher.[COLOR=Blue][FONT=Courier New]Filter[/FONT][/COLOR] [COLOR=Red][FONT=Courier New]=[/FONT][/COLOR] [COLOR=#666666][FONT=Courier New]"(objectClass=user)"[/FONT][/COLOR]
            [COLOR=Blue][FONT=Courier New]If[/FONT][/COLOR] [COLOR=Blue][FONT=Courier New]Len[/FONT][/COLOR](mstrLoginUserID) > 0 [COLOR=Blue][FONT=Courier New]Then[/FONT][/COLOR]
                dirSearcher.[COLOR=Blue][FONT=Courier New]Filter[/FONT][/COLOR] [COLOR=Red][FONT=Courier New]=[/FONT][/COLOR] [COLOR=#666666][FONT=Courier New]"(&"[/FONT][/COLOR] & dirSearcher.[COLOR=Blue][FONT=Courier New]Filter[/FONT][/COLOR] & [COLOR=#666666][FONT=Courier New]"(samaccountname="[/FONT][/COLOR] & mstrLoginUserID & [COLOR=#666666][FONT=Courier New]"))"[/FONT][/COLOR]
                [COLOR=Green][FONT=Courier New]'dirSearcher.Filter = "(&" & dirSearcher.Filter & "(memberof="???"))"[/FONT][/COLOR]
            [COLOR=Blue][FONT=Courier New]End[/FONT][/COLOR] [COLOR=Blue][FONT=Courier New]If[/FONT][/COLOR]

            mdirSearchResultat [COLOR=Red][FONT=Courier New]=[/FONT][/COLOR] dirSearcher.FindAll()[/FONT][/COLOR]


So, how can I check if the user is in the group "Domain Admins" (CN=Domain Admins,CN=Users,CN=Testdomain,DC=local)??

Pliz help, I'm rellay under stress and that code is everything I still need to complete my application (tomorrow it has to be done) :-(


Regards
 
come on guys, somebody has to know it...I'm sure I'm not the first one with that idea of checking a user's group... :-(

I can't find with google anything I could use...


Regards
 
Back
Top