none
Add LDAP server to my query fails RRS feed

  • Question

  • Hi
    I execute query via powershell, I want to specify a DC address, if I set the filter:
    $Filter = "(distinguishedname=CN=Add MPI4D1,OU=AdminEventsOU,DC=CI67,DC=com"
    $searcher.Filter = $Filter
    $searcher.FindAll()
    It works, but when i try to add a DC server address (or IP Address) like this:
    $Filter = "(LDAP://CI67-DC1.CI67.com/distinguishedname=CN=Add MPI4D1,OU=AdminEventsOU,DC=CI67,DC=com)"

    The query fails, note there is space in the DN.

    I also tried:
    $Filter = "(LDAP://CI67-DC1.CI67.com/CN=Add MPI4D1,OU=AdminEventsOU,DC=CI67,DC=com)"
    $Filter = "(LDAP://CI67-DC1.CI67.com/CN=Add\ MPI4D1,OU=AdminEventsOU,DC=CI67,DC=com)"
    $Filter = "(LDAP://CI67-DC1.CI67.com/distinguishedname=CN=Add\ MPI4D1,OU=AdminEventsOU,DC=CI67,DC=com)"

    What Am I missing ? Thanks !

    Sunday, March 11, 2018 2:12 PM

All replies

  • The target domain controller is not part of the LDAP filter.

    To specify it, use the searcher object -

    $Searcher=New-Object System.DirectoryServices.DirectorySearcher([ADSI]"LDAP://CI67-DC1.CI67.com")

    more at https://blogs.msdn.microsoft.com/javaller/2013/07/29/searching-across-active-directory-domains-in-powershell/

    hth
    Marcin


    Sunday, March 11, 2018 2:43 PM
  • Hi,

     

    Just checking in to see if the information provided was helpful. Please let us know if you would like further assistance.

     

    Best Regards,

    William


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Monday, March 12, 2018 8:06 AM
  • Hi,

     

    Was your issue resolved?

     

    If you resolved it using our solution, please "mark it as answer" to help other community members find the helpful reply quickly.

    If you resolve it using your own solution, please share your experience and solution here. It will be very beneficial for other community members who have similar questions.

    If no, please reply and tell us the current situation in order to provide further help.

     

    Best Regards,

    William


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Wednesday, March 14, 2018 10:42 AM
  • Hi,

     

    Please remember to mark useful reply as answer, which would be much more efficient for other forum community members to find useful information.

     

    Best Regards,

     

    William


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Monday, April 9, 2018 1:06 PM