I was wondering if there was a way to find a User in Active Directory that is LIKE what a user has typed and then post it back to a previous page within the application.
I have the following code
using (PrincipalContext ctx = new PrincipalContext(ContextType.Domain))
{
UserPrincipal queryAdUser = new UserPrincipal(ctx);
queryAdUser.SamAccountName = "Thomas";
using (PrincipalSearcher searchAdUser = new PrincipalSearcher(qbeUser))
{
foreach (UserPrincipal UsersFound in searchAdUser.FindAll())
{
DirectoryEntry res = UsersFound.GetUnderlyingObject() as DirectoryEntry;
Response.Write(res.Properties["givenName"].Value);
}
}
}
This currently only returns the user that matches the entered value by the user. So lets say I entered a search of "T" and I had in Active Directory "Tom, Ted and Tim" I want to return these users as results when the user searches.
Is it possable to alter the above code to perform this task, or this there a better way that I could be doing this?
Kind Regards