I'm creating a form that on start up will retrieve all "Name" properties from AD. I would like to select one of the names from the dropdown and be able to display all of the other attributes related to that one user name.
This is what I have so far.
Imports System.DirectoryServices
Public Class Form1
Inherits System.Windows.Forms.Form
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
F1 = Me
Dim objOU As New DirectoryEntry("LDAP://OU=Admins,OU=All Users,DC=DOMAIN,DC=COM")
Dim Child As DirectoryEntry
Try
For Each Child In objOU.Children
If Child.Properties("sAMAccountName").Value = "" Then
Else
cboUserAccount.Items.Add(Child.Properties("Name").Value)
End If
Next
Catch
MsgBox(Err.Number & " -- " & Err.Description)
End Try
cboUserAccount.DropDownStyle = ComboBoxStyle.DropDownList
End Sub
Private Sub cboUserAccount_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboUserAccount.SelectedIndexChanged
txtUserValue.Text = cboUserAccount.SelectedItem <- Would like to display other properties
End Sub
End Class
This is what I have so far.
Imports System.DirectoryServices
Public Class Form1
Inherits System.Windows.Forms.Form
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
F1 = Me
Dim objOU As New DirectoryEntry("LDAP://OU=Admins,OU=All Users,DC=DOMAIN,DC=COM")
Dim Child As DirectoryEntry
Try
For Each Child In objOU.Children
If Child.Properties("sAMAccountName").Value = "" Then
Else
cboUserAccount.Items.Add(Child.Properties("Name").Value)
End If
Next
Catch
MsgBox(Err.Number & " -- " & Err.Description)
End Try
cboUserAccount.DropDownStyle = ComboBoxStyle.DropDownList
End Sub
Private Sub cboUserAccount_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboUserAccount.SelectedIndexChanged
txtUserValue.Text = cboUserAccount.SelectedItem <- Would like to display other properties
End Sub
End Class