if (name.Length > 0)
{search_fn = "(givenname=" + name + "*)(sn=" + name + "*)(initials="+name+"*)";}
else
{ search_fn = ""; }
if (ulid.Length > 0)
{ search_ulid = "(samaccountname=" + ulid + "*)";}
else
{search_ulid = "";}
string filter = "(&(&(objectClass=user)(objectCategory=person))" +"(|"+ search_fn + search_ulid + "))";
DirectoryEntry searchRoot = new DirectoryEntry(path);
DirectorySearcher search = new DirectorySearcher(searchRoot);
search.Filter = filter;
search.SizeLimit = 50000;
search.PropertiesToLoad.Add("samaccountname");
search.PropertiesToLoad.Add("name");
search.PropertiesToLoad.Add("cn");
search.PropertiesToLoad.Add("givenname");
search.PropertiesToLoad.Add("initials");
search.PropertiesToLoad.Add("sn");
SearchResult result;
ArrayList allUsers = new ArrayList();
ArrayList prop = new ArrayList();
SearchResultCollection resultCol = search.FindAll();
if (resultCol != null)
No comments:
Post a Comment