我对VB很陌生,所以我想请你帮忙。我想在此代码中添加搜索功能。假设有人会搜索 sAMaccountname,他会收到该用户的电子邮件。我真的不知道如何使用 AD 中的属性,所以只有我拥有的是这个(我认为很容易找到结果:))。当我看到如何将 samaccountname 发送到电子邮件时,我想我也可以继续做其他事情。谢谢你。
Imports System.DirectoryServices
Imports System.DirectoryServices.ActiveDirectory
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim domains As DomainCollection = Forest.GetCurrentForest.Domains
For Each domain As Domain In domains
'MessageBox.Show(domain.Name)
ComboBox2.Items.Add(domain.Name)
Next
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim domain As DirectoryEntry = New DirectoryEntry("LDAP://ourdomain.com/OU=Users,OU=Czech Republic,OU=TEAD,DC=eu,DC=ourcompany,DC=com")
For Each child As DirectoryEntry In domain.Children
ComboBox1.Items.Add(child.Name)
Next
End Sub
End Class