Developers use active directory as central source of authentication , validation and response. To perform actions on Security Principals, one have to open up the connection with the active directory domain where the application will be installed.
Programmers should use PrincipalContext to establish the connection to active directory and this is done through the constructors , properties and Methods exposed by MSDN. PrincipalContext constructor accepts 7 argument types which are listed below
In my below tool, I am passing OU as the Container Object to perform the operations on Security Principals. Below tool can be used to validate the PrincipalContext and the Container being used, the purpose was to expose the CLASS functionality of PrincpalContext and the behavior of container property.
a) Ensure you insert the DN of the Container object.
eg: In my example , I am using my OU as a container object and the syntax would be
Principalcontext ( contexttype.domain,”mydomain.com”,OU=Testing,DC=mydomain,DC=com”)
When the above code gets compiled, there is a socket which validates the DN on the Active directory provided in the Container section and returns error, if
the DN is wrong!, this gives more clarity for the developers to understand the DN before releasing the code.
b) From a tool point of view, I am accepting the input from users , but the code can be hardcoded as shown above.
This tool was tested on Windows 2008 R2 and Windows Server 2012
.Net Framework 3.5 and above.
– OU DN ( eg: OU=Testing,DC=mydomain,DC=com)
Tool will provide with the Domain Controller FQDN and OU DN after validation.
Please rename the tool to exe post download.
PrincipalContext Domain Validator