Click here to Skip to main content
15,888,454 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
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:

C#
PrincipalContext oPrincipalContext = new PrincipalContext(ContextType.Domain, "systemName.domain.local", "CN=Users,DC=domain,DC=local",ContextOptions.SimpleBind |ContextOptions.SecureSocketLayer, sServiceUser,sServicePassword);


C#
PrincipalContext oPrincipalContext = new PrincipalContext(ContextType.Domain, "systemName.domain.local:636", "CN=Users,DC=domain,DC=local",ContextOptions.SimpleBind |ContextOptions.SecureSocketLayer, sServiceUser,sServicePassword);


C#
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.
Posted
Comments
SHANCHAT972 30-Aug-16 19:53pm    
Did you get a solution to this issue?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900