Hello,
I am trying to create a library using System.DirectoryServices.AccountManagement that will let users manage(add, delete, unlock,etc.) any Active Directory they want to manage. Whether they are using the code in a domain joined computer or not and supporting SSL.
I am able to make it work with domain joined computers. The problem I run into is creating the PrincipalContext from a non domain joined computer. This is all done in C# of course.
Here are the PrincipalContext connections I have tried and they all result in :
Unhandled Exception: System.DirectoryServices.AccountManagement.PrincipalServerDownException: The server could not be contacted. ---> System.DirectoryServices.Protocols.LdapException: The LDAP server
is unavailable.
at System.DirectoryServices.Protocols.LdapConnection.Connect()
at System.DirectoryServices.Protocols.LdapConnection.SendRequestHelper(DirectoryRequest request, Int32& messageID)
at System.DirectoryServices.Protocols.LdapConnection.SendRequest(DirectoryRequest request, TimeSpan requestTimeout)
at System.DirectoryServices.Protocols.LdapConnection.SendRequest(DirectoryRequest request)
at System.DirectoryServices.AccountManagement.PrincipalContext.ReadServerConfig(String serverName, ServerProperties& properties)
--- End of inner exception stack trace ---
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 ConsoleTesting.Program.Main(String[] args) in c:\Solutions\SCE\VS\com.thescegroup.libs.directory.ad\ConsoleTesting\Program.cs:line 124
My Attempts:
PrincipalContext oPrincipalContext = new PrincipalContext(ContextType.Domain, "systemName.domain.local", "CN=Users,DC=domain,DC=local",ContextOptions.SimpleBind |ContextOptions.SecureSocketLayer, sServiceUser,sServicePassword);
PrincipalContext oPrincipalContext = new PrincipalContext(ContextType.Domain, "systemName.domain.local:636", "CN=Users,DC=domain,DC=local",ContextOptions.SimpleBind |ContextOptions.SecureSocketLayer, sServiceUser,sServicePassword);
PrincipalContext oPrincipalContext = new PrincipalContext(ContextType.Domain, "LDAP://systemName.domain.local:636", "CN=Users,DC=domain,DC=local",ContextOptions.SimpleBind |ContextOptions.SecureSocketLayer, sServiceUser,sServicePassword);
NOTE: This works if I run it in a domain joined computer.
is AccountManager capable of attaching to any remote Active Directory? I want to do it using AccountManager and not DirectoryServices.
Any help is much appreciated.
Thanks in advance.