Lösning: (Sorry för reduntanta trådar)
http://www.webforum.nu/showthread.php?s=&threadid=109573&forumid=29
1 svar · 260 visningar · startad av T_Codez
Hej
Jag skulle vilja kunna göra sökningar med vildcards vid sökningar
via/i Active Directory.
Är det möjligt? Och i sådana fall hur?
I koden nedan får jag ut ett namn. Men jag får inte ut det om jag inte skriver exakt vad jag söker.
private void button1_Click(object sender, System.EventArgs e)
{
string dom = textBox1.Text;
string usr = textBox4.Text;
System.DirectoryServices.DirectoryEntry entry = new System.DirectoryServices.DirectoryEntry("LDAP://" +dom );
System.DirectoryServices.DirectorySearcher mySearcher = new System.DirectoryServices.DirectorySearcher(entry);
mySearcher.Filter = "(&(objectClass=user)(Name="+ usr +"))";
foreach(System.DirectoryServices.SearchResult resEnt in mySearcher.FindAll())
{
try
{
System.DirectoryServices.DirectoryEntry de = resEnt.GetDirectoryEntry();
// textBox3.Text = textBox3.Text + de.Properties["name"].Value.ToString() + "\r\n";
textBox3.Text = textBox3.Text + de.Properties["name"].Value.ToString();
//InitializeListView();
}
catch(Exception ex)
{
}
}
}
Lösning: (Sorry för reduntanta trådar)
http://www.webforum.nu/showthread.php?s=&threadid=109573&forumid=29