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)

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
vps
  • 1,337
  • 7
  • 23
  • 41

1 Answers1

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
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • thank u so much for ur reply. how to check whether particular user exists in active directory – vps Oct 04 '12 at 06:36
  • @sudha.s: that's a whole new question - please post a new question so we can answer ... – marc_s Oct 04 '12 at 07:29