SourceCode. Получение данных из ActiveDirectory

Скачать пример

Public Class Form1

Private Property objSysInfo As Object
Private Property strUser As Object
Private Property objUser As Object
Private Property objGroup As Object
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Try
objSysInfo = CreateObject("ADSystemInfo")
strUser = objSysInfo.UserName
objUser = GetObject("LDAP://" & strUser)
txtBox_FIO.Text = objUser.displayName

Dim strS As String, myArr
strS = objSysInfo.UserName
myArr = Split(strS, ",OU=")
TextBox_Department.Text = myArr(1)
Catch ex As Exception
MsgBox("Не удалось определить пользователя. Проверь настройки")
End Try
End Sub
End Class