Anonymous_User Absent Member.
Absent Member.
2400 views

C# ldap connect() fails over SSL on Windows

Hi all,

I'm running the following code:

string pwd = "password";
string user = "cn=admin,o=lab";
string host = "10.0.0.10";
int port = 636;
lc.UserDefinedServerCertValidationDelegate += new CertificateValidationCallback(CertificateVerificationCallBack);
lc.SecureSocketLayer = true;
lc.Connect(host, port);
lc.Bind(user, pwd);

public static bool CertificateVerificationCallBack(
System.Security.Cryptography.X509Certificates.X509Certificate
serverCert,
int[] target)
{
return true;
}

This fails with the following error:

System.NullReferenceException: Object reference not set to an instance of
an obj
ect.
at Novell.Directory.Ldap.Connection.connect(String host, Int32 port, Int32
se
maphoreId)
at Novell.Directory.Ldap.Connection.connect(String host, Int32 port)
at Novell.Directory.Ldap.LdapConnection.Connect(String host, Int32 port)
at UPSync.Program.Main(String[] args) in C:\Johan\Visual Studio 2005\Projects
\NovCSLDAPTest\NovCSLDAPTest\Program.cs:line 23

Any suggestions?

Regards johan


Labels (1)
0 Likes
5 Replies
Anonymous_User Absent Member.
Absent Member.

Re: C# ldap connect() fails over SSL on Windows

Hello Johan,

Ahh, that stupid mono.security.dll thing again. Can't the Novell Ldap lib
throw an error saying it's likely to be the file.
Learn from JBoss who tries to include a message about which section in the
J2EE specification has been violated when an error occurs.

Regards Johan

> Hi all,
>
> I'm running the following code:
>
> string pwd = "password";
> string user = "cn=admin,o=lab";
> string host = "10.0.0.10";
> int port = 636;
> lc.UserDefinedServerCertValidationDelegate += new
> CertificateValidationCallback(CertificateVerificationCallBack);
> lc.SecureSocketLayer = true;
> lc.Connect(host, port);
> lc.Bind(user, pwd);
> public static bool CertificateVerificationCallBack(
>
> System.Security.Cryptography.X509Certificates.X509Certificate
> serverCert,
> int[] target)
> {
> return true;
> }
> This fails with the following error:
>
> System.NullReferenceException: Object reference not set to an instance
> of
> an obj
> ect.
> at Novell.Directory.Ldap.Connection.connect(String host, Int32
> port, Int32
> se
> maphoreId)
> at Novell.Directory.Ldap.Connection.connect(String host, Int32
> port)
> at Novell.Directory.Ldap.LdapConnection.Connect(String host, Int32
> port)
> at UPSync.Program.Main(String[] args) in C:\Johan\Visual Studio
> 2005\Projects
> \NovCSLDAPTest\NovCSLDAPTest\Program.cs:line 23
> Any suggestions?
>
> Regards johan
>



0 Likes
Anonymous_User Absent Member.
Absent Member.

Re: C# ldap connect() fails over SSL on Windows


We are having the exact same issue with a 2003 R2 server running on a
VM.

- It only seems to happen with the SSL enabled.
- We have the LDAP server and the web server on the same box.
- It works fine when we run the LDAP on the 2003 R2 and IIS on a
different box (XP).
- We checked the permissions for the client certificate in the All
Users\.mono directory can be read by the w3 worker process


--
reskin
------------------------------------------------------------------------
reskin's Profile: http://forums.novell.com/member.php?userid=61771
View this thread: http://forums.novell.com/showthread.php?t=365073

0 Likes
Anonymous_User Absent Member.
Absent Member.

Re: C# ldap connect() fails over SSL on Windows


Johan Akerstrom;1756910 Wrote:
> Hi all,
>
> I'm running the following code:
>
> string pwd = "password";
> string user = "cn=admin,o=lab";
> string host = "10.0.0.10";
> int port = 636;
> lc.UserDefinedServerCertValidationDelegate += new
> CertificateValidationCallback(CertificateVerificationCallBack);
> lc.SecureSocketLayer = true;
> lc.Connect(host, port);
> lc.Bind(user, pwd);
>
> public static bool CertificateVerificationCallBack(
> System.Security.Cryptography.X509Certificates.X509Certificate
> serverCert,
> int[] target)
> {
> return true;
> }
>
> This fails with the following error:
>
> System.NullReferenceException: Object reference not set to an instance
> of
> an obj
> ect.
> at Novell.Directory.Ldap.Connection.connect(String host, Int32 port,
> Int32
> se
> maphoreId)
> at Novell.Directory.Ldap.Connection.connect(String host, Int32 port)
> at Novell.Directory.Ldap.LdapConnection.Connect(String host, Int32
> port)
> at UPSync.Program.Main(String[] args) in C:\Johan\Visual Studio
> 2005\Projects
> \NovCSLDAPTest\NovCSLDAPTest\Program.cs:line 23
>
> Any suggestions?
>
> Regards johan


Hi Johan,

Did you figure this out? I have the same issue. I think I have done all
the things but gets an "unknown" NullReferenceException. Any
suggestions?

//Calle


--
calleT
------------------------------------------------------------------------
calleT's Profile: http://forums.novell.com/member.php?userid=57855
View this thread: http://forums.novell.com/showthread.php?t=365073

0 Likes
Highlighted
Anonymous_User Absent Member.
Absent Member.

Re: C# ldap connect() fails over SSL on Windows


calleT;1851593 Wrote:
> Hi Johan,
>
> Did you figure this out? I have the same issue. I think I have done all
> the things but gets an "unknown" NullReferenceException. Any
> suggestions?
>
> //Calle


There is a reliance on Mono.Security.dll which is causing this error.


Download that from somewhere (I ended up searching for
Mono.Security.dll and finding it packaged in something else), add it as
a reference to your project, retry and it should be right!


--
supertravio
------------------------------------------------------------------------
supertravio's Profile: http://forums.novell.com/member.php?userid=72310
View this thread: http://forums.novell.com/showthread.php?t=365073

0 Likes
Anonymous_User Absent Member.
Absent Member.

Re: C# ldap connect() fails over SSL on Windows


NullReferenceException indicates that you are trying to access member
fields, or function types, on an object reference that points to null.
That means the reference to an Object which is not initialized. More
details with example....'NullReferenceException'
(http://net-informations.com/q/faq/null.html)


--
brianmanee
------------------------------------------------------------------------
brianmanee's Profile: https://forums.netiq.com/member.php?userid=10254
View this thread: https://forums.netiq.com/showthread.php?t=2678

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.