I'm having trouble obtaining a user from an Active Directory server when using SSL. The following code block works fine up unti the FindByIdentity
call when it is throwing a System.DirectoryServices.DirectoryServicesCOMException - An operations error occurred
exception.
options = ContextOptions.SimpleBind | ContextOptions.SecureSocketLayer;
using (var context = new PrincipalContext(ContextType.Domain, "mycompany.org:636", null, options))
{
if (!context.ValidateCredentials(name, password, options))
{
LdapStatus = 0;
return null;
}
UserPrincipal user = UserPrincipal.FindByIdentity(context, name);
... other stuff to find groups ...
}
Interestingly, if I use options = ContextOptions.SimpleBind
without the SSL flag or if go to port :389
together with the options options = ContextOptions.Negotiate | ContextOptions.Signing | ContextOptions.Sealing
it works just fine. So I guess it has something to do with FindByIdentity
not working with SSL? But I have seen examples (such as here) that this should indeed work.
Anything obvious that I'm doing wrong here?
Btw. I'm running on .NET 4.8