Re: LDAP and Organization group

From: Vishal_7 (Vishal7_at_discussions.microsoft.com)
Date: 07/13/05

  • Next message: Karen Hodge: "Configuration Error"
    Date: Wed, 13 Jul 2005 12:27:02 -0700
    
    

    Thanks Joe,

      I have another question. I am now able to get the OU list. Now I need to
    get the users in that specific OU. For that purpose I created a new
    DirectoryEntry obj and pased the path, as well as username and pw to it.
    After that I am setting the path again for that specific OU.

    Dim entry As DirectoryEntry = New DirectoryEntry("LDAP://DOMAIN",
    "Username", "pw")
    entry.Path = "LDAP://OU=stores,DC=DOMAIN,DC=local"

    now, this code works locally, but does not work on the server. The username
    and pw is hardcoded for the moment. The user is domain admin. Later, I will
    would like to use the logged in user and pw. Can you please help me why this
    is not working on the server?

    Thanks
    "Joe Kaplan (MVP - ADSI)" wrote:

    > If you want to search within a specific OU, specify the OU's distinguished
    > name in your LDAP path:
    >
    > LDAP://MYDOMAIN/OU=MyOU,DC=MYDOMAIN
    >
    > Also, if you only want to search that particular OU, but no sub-OUs, set
    > your SearchScope to OneLevel.
    >
    > Also, for your DirectorySearcher to return an properties, you must add the
    > ones you want to the PropertiesToLoad property.
    >
    > You should also specify AuthenticationTypes.Secure if you are going to
    > specify credentials with your DirectoryEntry unless you want your password
    > passed on the network in clear text.
    >
    > Joe K.
    >
    > "Vishal_7" <Vishal_7@discussions.microsoft.com> wrote in message
    > news:6EE9B6B3-7503-4669-8CCC-1BB117D069A0@microsoft.com...
    > >
    > > Hey,
    > >
    > > I am trying to get the users from a specific OU, however it doesnt work
    > > properly. So far I have this code:
    > >
    > > Dim entry As DirectoryEntry = New DirectoryEntry("LDAP://MYDOMAIN",
    > > "MYDOMAIN\username", "pwd")
    > >
    > > Dim searcher As DirectorySearcher = New DirectorySearcher(entry)
    > > Dim searchResult As SearchResult
    > > Dim mySearchResultColl As SearchResultCollection
    > > Dim myResultPropColl As ResultPropertyCollection
    > >
    > > searcher.Filter = ("(&(objectClass=user))")
    > > mySearchResultColl = searcher.FindAll()
    > > Dim dt As New DataTable
    > > If mySearchResultColl.Count > 0 Then
    > > dt.Columns.Add("UserID")
    > > dt.Columns.Add("DisplayName")
    > >
    > > Dim sr As SearchResult
    > > For Each sr In mySearchResultColl
    > > Response.Write(sr.Path)
    > > myResultPropColl = sr.Properties
    > > 'Dim myDE(myResultPropColl.Count) As DictionaryEntry
    > > 'myResultPropColl.CopyTo(myDE, 0)
    > >
    > > Dim strUserID As String =
    > > myResultPropColl("samaccountname")(0)
    > > If strUserID.IndexOf("$") = -1 Then
    > > Dim dr As DataRow = dt.NewRow
    > > dr("UserID") = strUserID
    > > dr("DisplayName") = myResultPropColl("Name")(0) & " -
    > > ("
    > > & strUserID & ")"
    > > dt.Rows.Add(dr)
    > > End If
    > > Next
    > >
    > > dt.DefaultView.Sort = "UserID"
    > > End If
    > >
    > > Where can I now define the OU?
    > >
    > > Many thanks
    >
    >
    >


  • Next message: Karen Hodge: "Configuration Error"

    Relevant Pages

    • Re: DirectoryService and get all groups
      ... Dim dsGroups As New DirectorySearcher(dirEnt, ... Dim srGroupsCol As SearchResultCollection = dsGroups.FindAll ... Dim srGroups As SearchResult ... properties of the objectCategory of group. ...
      (microsoft.public.dotnet.framework.aspnet.security)
    • Re: LDAP, Email
      ... SearchResult and then you go and create another DirectoryEntry just to read ... strEmail = DirectCast, String) ... Dim oDS As New DirectorySearcher ...
      (microsoft.public.dotnet.security)
    • Re: LDAP query to DataGrid
      ... Dim dt As New DataTable ... Dim SearchResult As SearchResult ... Protected Sub Page_Load ... > Partial Class _Default ...
      (microsoft.public.dotnet.framework.aspnet)
    • Re: How can I list all the users in a particular security group with ASP.NET?
      ... Sub Page_Load ... Dim searcher As New DirectorySearcher ... Dim result As SearchResult, strDept As String, strOldDept As String ...
      (microsoft.public.dotnet.framework.aspnet.security)
    • Re: LDAP, Email
      ... SearchResult and then you go and create another DirectoryEntry just to read ... strEmail = DirectCast, String) ... Dim oDS As New DirectorySearcher ...
      (microsoft.public.dotnet.security)