This project is read-only.

Search multiple domains in AD

Aug 14, 2013 at 10:11 PM
Is it possible to search multiple domains for AD users? other than looping through them individually?

We have a domain called NA, AP, and others
var config = new LdapConfiguration();
using (var context = new DirectoryContext(config))
    context.Log = Console.Out;

    var user = context.Query<User>()
        .Where(u => u.CommonName.StartsWith("username"))
[DirectorySchema("DC=na,DC=xxxxx,DC=com", ObjectClass = "User")]
public class User : DirectoryObjectBase
    public string DistinguishedName { get; set; }

    [DirectoryAttribute("cn", ReadOnly = true)]
    public string CommonName { get; set; }

    public string Title { get; set; }

    [DirectoryAttribute(StoreGenerated = true)]
    public Guid ObjectGuid { get; set; }

    [DirectoryAttribute(StoreGenerated = true)]
    public SecurityIdentifier ObjectSid { get; set; }

    [DirectoryAttribute(StoreGenerated = true)]
    public DateTime WhenChanged { get; set; }
Aug 18, 2013 at 5:08 AM
I've handled it in the past by querying the global catalog. Our directory administrators had set up replication from the parent domain and our domain (we were a subsidiary company) to the global catalog that had all of the information we needed.
Aug 18, 2013 at 5:14 AM
Can you show me an example code how you query the global catalog?

Aug 19, 2013 at 5:03 PM
Typically the global catalog is hosted on port 3268. When building your connection factory you can change the default port:
var config = new LdapConfiguration();