webForumDet fria alternativet

AD fler "fält" samt sökning på Wildcards ???

.NET

1 svar · 260 visningar · startad av T_Codez

Medlem sedan juli 2001458 inlägg
Frågan#1

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)
			{
			}
		}
	}
Medlem sedan juli 2001458 inlägg
#2

Lösning: (Sorry för reduntanta trådar)

http://www.webforum.nu/showthread.php?s=&threadid=109573&forumid=29

258 ms totalt · 4 externa anrop · v20260731065814-full.86ec41c2
121 ms — deklarationer (db)
0 ms — hämta statistik (cache)
129 ms — hämta tråd, inlägg och bilagor (db)
126 ms — ändringar (db)