Reputation: 158
I get stuck with following problem:
I want to use Synologys LDAP Service. Works fine. My config is:
Now I have to check credentials from my c# .net application (.net 6). I would prefer using PrincipalContext rather than ldapconnection. But Whatever I do to create the PrincipalContext I always get errors. My code is:
string Domain = "192.168.178.79:389";//"192.168.178.79:636";
string dn = "dc=ldap,dc=local";
string User = "uid=admin,cn=users,dc=ldap,dc=local";
string Password = "iWillNotTellYouHere";
ContextOptions options = ContextOptions.SimpleBind;// | ContextOptions.SecureSocketLayer;
PrincipalContext context = new PrincipalContext(ContextType.Domain, Domain, dn, options, User, Password);
The constructor crashes with NullReferenceException
I checked connection with Softerra LDAP Browser and it works fine with and without SSL. Using following params:
Any Ideas ???
The stack trace is:
System.NullReferenceException
HResult=0x80004003
Nachricht = Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.
Quelle = System.DirectoryServices.AccountManagement
Stapelüberwachung:
at System.DirectoryServices.AccountManagement.PrincipalContext.ReadServerConfig(String serverName, ServerProperties& properties)
at System.DirectoryServices.AccountManagement.PrincipalContext.DoServerVerifyAndPropRetrieval()
at System.DirectoryServices.AccountManagement.PrincipalContext..ctor(ContextType contextType, String name, String container, ContextOptions options, String userName, String password)
at DomainTest.Form1.button3_Click(Object sender, EventArgs e) in N:\Matthias\source\repos\DomainTest\DomainTest\Form1.cs:line 35
Upvotes: 0
Views: 580
Reputation: 158
OK now I know the problem source:
PrincipalContext can't handle OpenLDAP connections
I will have to use DirectoryEntry
Upvotes: 0