Hi guys
I'm allowing users to search my SQL database for Projects created by a
certain user. The user login stuff is all stored in AD.
Atm, I can get it to work so that if they type the full name "Dan Nash" for
example, it returns all the Projects I created.
However, it's a tad long-winded.
What I'd like to do is enable them to search for "Dan" and it find all my
projects, as well as any projects by other Dans.
I'm using the DisplayName property to get the samaccountname to search the
database with. Is there a way to do a LIKE type search on displayname?
Here's my current code...
private string PullADUserFromDisplayName(string displayName)
{
DirectoryEntry entry = new DirectoryEntry("LDAP://" +
ConfigurationSettings.AppSettings.Get("System_Acti veDirPath"));
DirectorySearcher mySearcher = new DirectorySearcher(entry);
mySearcher.Filter = "(&(objectClass=user)(displayname=" + displayName + "))";
SearchResult resEnt = mySearcher.FindOne();
try
{
return resEnt.Properties["samaccountname"][0].ToString();
}
catch
{
return "null";
}
}
Any help appreciated.
Cheers
Dan