VB.NET LDAP连接,无法显示OU = Users

时间:2013-11-15 13:18:20

标签: vb.net ldap

我在测试服务器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

有关错误原因的任何想法吗?

1 个答案:

答案 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。