Skip to content

DirectoryOperationException – The object does not exist.

October 20, 2011

System.DirectoryService.Protocols Library

This was a very frustrating error. I was able to connect to LDAP through LDAPadmin but not through a program I was creating. “The object does not exist” error occurs, at least in my experience when the credentials you are passing to the server┬ádo not authenticate.

In this case I was getting nowhere. Resorting to Wireshark, filtering against port 389, which is the port for LDAP resulted in me seeing a backslash in the credentials being passed as well as the username coming after the organization, which is wrong for my environment.

The resolution was to set the domain to nothing in VB or null in C# in my Net.NetworkCredential object. At the same time moving the organization to the username property.

Dim credLDAP As New Net.NetworkCredential(“cn=username”,”password”, “o=domain”)
does not work, but this does:
Dim credLDAP As New Net.NetworkCredential(“cn=username,o=domain”,”password”, nothing)

About these ads

From → Dot Net, Powershell

3 Comments
  1. ‘cn=username’ is likely not a distinguished name, unless of course it is the naming context hosted or shadowed by the directory server. Clients can discover the naming contexts of directory server by querying the root DSE.

    • That is a good point. I was under the assumption on my first attempt to allow the NetworkCredential to build the distinguished name for me. I was clearly wrong on that. Your blog looks very interesting. I am just getting started in LDAP from a programming point of view. I will have to check out your introduction on the subject.

  2. I’d vetnrue that this article has saved me more time than any other.

Have an opinion? Leave an opinion!

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 33 other followers

%d bloggers like this: