On Mar 6, 6:51*pm, "Jim in Arizona" <tiltow...@hotmail.com> wrote:
> I've been searching a lot for a simple example to search for a single
> account name in active directory but have been unable to find what I'm
> looking for. I did find an exmple (that worked) that pulls out all names in
> the AD but that isn't what I need.
>
> My goal is to check the AD for a username that matches
> Request.ServerVariables("AUTH_USER"). That would be the first step. The next
> step would be to see what security or distribution group they're in (in AD)
> and redirect them based on that information.
>
> This is the code that searches the entire directory and returns EVERYONE. I
> suppose this would be useful only if I knew how to search the list for a
> single name.
>
> ======================================================
>
> Dim oroot As DirectoryEntry = New
> DirectoryEntry("LDAP://corp.commspeed.net")
> * * * * Dim osearcher As DirectorySearcher = New DirectorySearcher(oroot)
> * * * * Dim oresult As SearchResultCollection
> * * * * Dim result As SearchResult
>
> * * * * osearcher.Filter = "(&(objectCategory=person))" ' search filter
Use
(&(objectCategory=Person)(cn=user_name_here))
or
(&(objectCategory=Person)(sAMAccountName=user_name_here))
Hope this helps
|