我在测试服务器2008中阅读OU=Users
时出现问题,但是OU=People
(我已创建)有效。错误,它告诉我的是:
服务器上不存在此对象
Imports System.DirectoryServices
Imports System.DirectoryServices.ActiveDirectory
Imports System.Text
Imports System
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ADVstup As New DirectoryEntry("LDAP://192.168.1.1/OU=People,DC=pokus,DC=local", "Administrator", "Administrator")
Dim ADVyhledani As New DirectorySearcher(ADVstup)
Dim vysledky As SearchResultCollection
Dim vysledek As SearchResult
vysledky = ADVyhledani.FindAll
For Each vysledek In vysledky
MessageBox.Show(vysledek.GetDirectoryEntry.Properties("sAMAccountName").Value)
Next
End Sub
End Class
有关错误原因的任何想法吗?
答案 0 :(得分:0)
答案在另一篇文章LDAP Directory Entry in .Net - not working with OU=Users
中这看似愚蠢和愚蠢,但Active Directory中的默认树设置是而不是OU =用户,dc =域,dc = com,而是 CN =用户 ,dc = domain,dc = com(注意CN =不是OU = for Users。