Ik ben bezig met een programma dat alle gedisabelde accounts uit ons AD netwerk moet kunnen ophalen. Het is zo goed als af buiten 1 ding waardoor er niets werkt. Ik kan namelijk de 'name' (fullname eigelijk) van de account opvragen maar niet de username (loginnaam) die ik juist nodig heb.
Weet er iemand hoe ik dit wel kan oplossen?
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
| Private Sub cmdZoeken_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdZoeken.Click
Dim enTry As DirectoryEntry = New DirectoryEntry("LDAP://pcbebr.local")
Dim mySearcher As DirectorySearcher = New DirectorySearcher(enTry)
mySearcher.Filter = "(&(objectClass=user)(objectCategory=person))"
mySearcher.SearchScope = SearchScope.Subtree
Dim resEnt As SearchResult
For Each resEnt In mySearcher.FindAll
Dim strUser As String = ""
strUser = Mid(resEnt.GetDirectoryEntry.Name.ToString, 4)
If IsAccountDisabled("pcbebr.local", strUser) Then
ListBox.Items.Add(strUser)
End If
Next
End Sub
Function IsAccountDisabled(ByVal strDomain As String, ByVal strAccount As String)
Dim objUser As Object
objUser = GetObject("WinNT://" & strDomain & "/" & strAccount & ",user")
IsAccountDisabled = objUser.AccountDisabled
End Function |
Weet er iemand hoe ik dit wel kan oplossen?