I need to create a contact in Active Directory. I have a class that extends UserPrincipal. How do I use it to create a new contact? The code below throws PrincipalOperationException " The requested operation did not satisfy one or more constraints associated with the class of the object." exception.
[DirectoryObjectClass("contact")]
[DirectoryRdnPrefix("CN")]
internal class MyContact : UserPrincipal
{
public MyContact(PrincipalContext context)
:base(context)
{
}
}
using (PrincipalContext pc = new PrincipalContext(ContextType.Domain, "domain",
"OU=Unit1,DC=domain,DC=com", "login", "pass"))
{
using (MyContact principal = new MyContact(pc))
{
principal.Name = "Cnt1";
principal.Save();
}
}
What am I doing wrong?