Searching Active Directory with .NET - (and FURST POHST)
When searching Active Directory using C#.NET, you don't build a filter by reassinging the DirectorySearcher.Filter attribute with different filter values. You have to rebuild the string each time you add a filter.
For instance, this won't work:
DirectorySearcher ds = new DirectorySearcher(ldapPath);
ds.Filter = "(objectClass=user)";
ds.Filter = "(objectCategory=person)";
You have to do something like this:
DirectorySearcher ds = new DirectorySearcher(ldapPath);
StringBuilder filters = new StringBuilder("(");
filters.Append("(objectClass=user)");
filters.Append("(objectCategory=person)");
filters.Append(")");
ds.Filter = filters;
See you tomorrow.
1 Comments:
Brilliant idea. I'll keep checking it out. Maybe I'll learn something....
Maybe I should start a blog about what I didn't learn again today.
Post a Comment
<< Home