Getting error in DirectoryEntry using vb.net

2

I am using vb.net and the following code, but I am getting an error. I am new to vb.net and Active Directory, pls help me to solve this problem.

My code:

Dim dirEntry As DirectoryEntry = New DirectoryEntry()
    dirEntry.Path = "ldap://sunbs.in:389/CN=Schema,CN=Configuration,DC=sunbs,DC=in"
    dirEntry.Username = "sunbs.in\sbsldap"
    dirEntry.Password = "sbs@123"
    Dim searcher As New DirectorySearcher
    searcher.SearchRoot = dirEntry

When I debug the code the I get error in 2nd line. unknown error(0X80005000)

vb.net
active-directory
ldapconnection
asked on Stack Overflow Oct 4, 2012 by vps • edited Oct 4, 2012 by marc_s

1 Answer

1

Try to use an UPPERCASE LDAP:// prefix for your dirEntry.Path:

Dim dirEntry As DirectoryEntry = New DirectoryEntry()

' use LDAP:// - not ldap://
dirEntry.Path = "LDAP://sunbs.in:389/CN=Schema,CN=Configuration,DC=sunbs,DC=in" 

dirEntry.Username = "sunbs.in\sbsldap"
dirEntry.Password = "sbs@123"
Dim searcher As New DirectorySearcher
searcher.SearchRoot = dirEntry
answered on Stack Overflow Oct 4, 2012 by marc_s

User contributions licensed under CC BY-SA 3.0