I know similar questions have been asked a million times. I've read them and I still cannot get to the bottom of this. I'm using the Novell.Directory.Ldap c# library in my code (Winforms, c#). It works very similar to the microsoft ldap libraries but it can also access the attributes specific to Novell eDirectory.
using Novell.Direcotry.Ldap; is in there. I also added the reference and pointed it to the Novell.Directory.Ldap.dll file.
string LDAPServerIP = "12.34.56.78";
string serverUserName = "cn=Rrunner,o=acme";
string serverPassword = "@nvi1";
LdapConnection ldapConn = new LdapConnection();
MessageBox.Show(ldapConn.ToString());
ldapConn.SecureSocketLayer = true;
ldapConn.Connect(LDAPServerIP, 636);
ldapConn.Bind(serverUserName, serverPassword);
I get a NullReferenceException when it gets to the ldapConn.Connect() method. Stepping through in the debugger is can see the ldapConn object, and it is a Novell.Directory.Ldap.LdapConnection object and seems to have sensible values assigned to it. For example, it does get SSL set to true, and at the point of the exception it even has already had the Host(string) variable set to the LDAPServerIP, and the Port(int) set to 636 just as the ldapConn.Connect() ordered. Given this information, I put a try/catch on just that statement to get past it since it is putting the attribute in anyways. It then will also get the exception on the Bind() method, and bind did put the appropriate values (userDN and password) into the object as well.
That section of code I copied directly from another program I use/write and it works perfectly fine in that so I don't know why it shouldn't work in this program. The only difference is that this is a differnt project in Visual Studio.
Given that, I've tried going through the things again that could be different because its a different project:
I've tried verifying that the reference to the Novell supplied is in the project. I'm fairly certain that part must be working because the object in memory is of the correct type and has a bunch of attributes that my program doesn't tell it about so they had to come from that dll file.
The SSL cert exists on my computer in a spot where .net can find it as this is the same computer that I develop the program that does connect to LDAP successfully.
What am I misssing? It seems like it has to be something really simple.