469,904 Members | 2,100 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,904 developers. It's quick & easy.

AD searches using LIKE

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();
return resEnt.Properties["samaccountname"][0].ToString();
return "null";

Any help appreciated.

Nov 19 '05 #1
0 854

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by ArunPrakash | last post: by
1 post views Thread by boblotz2001 | last post: by
8 posts views Thread by DQ dont quit | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.