Hi @Jaime Stuardo ,
I suggest you look at the documentation for the PrincipalContext constructor, it should be clear:
https://learn.microsoft.com/en-us/dotnet/api/system.directoryservices.accountmanagement.principalcontext.-ctor?view=dotnet-plat-ext-6.0#system-directoryservices-accountmanagement-principalcontext-ctor(system-directoryservices-accountmanagement-contexttype-system-string-system-string)
public PrincipalContext(ContextType contextType, string name, string container)
So you basically need:
- your context type(Connect to domain (using ContextType.Domain))
- the domain name(The name part of this principal context can be set to an IP address of a domain controller.)
- optionally a container
For example:
new PrincipalContext(ContextType.Domain, "xyz.mycorp.com:****", "DC=mycorp,DC=com");
new PrincipalContext(ContextType.Domain, "mycompany.local", "OU=Marketing,OU=Operations,OU=Applications,DC=mycompany,DC=local");
Best regards,
Lan Huang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.