"RJN" <rj*@yahoo.comwrote in message news:el**************@TK2MSFTNGP02.phx.gbl...
Hi
I've written a code that queries Windows LDAP server and works fine, but
the same doesn't work when querying Solaris LDAP server.
DirectoryEntry de = new DirectoryEntry("LDAP://server.com");
DirectorySearcher ds = new DirectorySearcher(de);
de.Username = "xxx";
de.Password = "yyy";
de.AuthenticationType = AuthenticationTypes.Secure;
ds.Filter = ("(SAMAccountName=xxx)");
SearchResult sr = ds.FindOne();
Without setting the login credentials I get error that "Server is not
operational". if I set the logon details, I'm getting an error that
"Logon failure, unknown user name or bad password".
Can anyone give me sample code to query Solaris LDAP server?
Regards
Rjn
*** Sent via Developersdex http://www.developersdex.com ***
Don't use the DirectoryEntry class to start with, use the LDAP wrapper class namespace
System.DirectoryServices.Protocols instead.
A few warning though, Solaris isn't Windows, so you won't find a property named
"sAMAccountName", what exactly are you trying to achieve?
Note that you won't be able to use Secure credentials if the LDAP server doesn't integrate
with other authentication providers on Solaris, use the LdapConnection and start with a
simple bind, when this works, you can try other more secure authentication types.
Here's a sample snip....
using System;
using System.DirectoryServices.Protocols;
using System.Net;
....
// :389 is optional, it's the default listener port! Make sure the Ldap server
listens on this port, else you have to set the port accordingly
using (LdapConnection ldap = new LdapConnection("server.com:389")) {
ldap.AuthType = AuthType.Basic;
ldap.Bind(new NetworkCredential("userName", "usersPwd"));
...
}
Willy.