Last post Aug 04, 2009 07:22 PM by Ertac
Aug 04, 2009 03:54 PM|Ertac|LINK
Since I'm a newcomer in this society, this is my first post. I've been experiencing a problem with my application that I haven't been able to figure out.
It's about LDAP filtering I guess, but I can't make any progress and kinda stuck with it.
Here are details:
I have 4 security groups called under Vancouver OU which is under domain cbv.dns :
Van Divisional Managers
Van Divisional Supervisors
When I run the following LDAP query through Active Directory's own search tool, it works.
(objectClass=user)(|(memberOf=cn=Van Divisional Supervisors,ou=Vancouver, dc=cbv, dc=dns)(memberOf=cn=Van Supervisors,ou=Vancouver, dc=cbv, dc=dns)(memberOf=cn=Van Divisional Managers,ou=Vancouver, dc=cbv, dc=dns)(memberOf=cn=Van Managers,ou=Vancouver, dc=cbv,
I mean this query returns me all users being member of the 4 security groups listed above.
But, when I use the sane filter in my ASP.NET application. It doesn't work and returns no results.
Here I am also including my code to make my explanations more clear :
path : "LDAP://DC=cbv, DC=dns" (Domain name is : cbv.dns)
filter : Same as the one written above
internal EmployeeData GetUsers(string path, string filter) //this method is under a different namespace then the next one
IData resultSet = new EmployeeData();
DirectorySearcher ds = new DirectorySearcher(new DirectoryEntry(path, "username", "password"));
ExecuteReader(ref resultSet, ds, filter);
protected void ExecuteReader(ref IData resultSet, DirectorySearcher ds, string filter)
DSESearcher.Filter = filter;
SearchResultCollection result = return DSESearcher.FindAll();
if (result != null)
When I run debugger, after executing FindAll() method and returning values, when I hover on "result" variable at the line containing if condition.
result.Count property throws an exception saying this:
'result.Count' threw an exception of type 'System.DirectoryServices.DirectoryServicesCOMException'
after second hover attempt:
result.Count shows "0"
As the same filter is returning the result in AD's own querying tool, then what could be the reason of not being able to return any result when my application is run?
Any help would appreciated very much, thanks in Advance.
Aug 04, 2009 07:22 PM|Ertac|LINK
Thank you for your attention anyway!
Problem was something that I didn't expected at all.
Instead of DataSets, I isually store datas in my related user defined classes as properties. Then I store data containing classes in Class Lists.. (List<T>)
In my case, I just define a class once and filled it with data coming from AD. Then instead of defining a new variable from same class type, i used the same one and tried to fill it with some other data retrieved from AD. It caused that trouble.
Having defined new variable from same class and filling it with data from AD, I didn't get same error.
Have a great day!