I'm trying to create a user and add a certain user to an Active Directory group using C#.
The user creation is working properly, but adding user to groups is throwing an exception
Information about the domain could not be retrieved (1355)
Here is my code:
using (PrincipalContext pc = new PrincipalContext(ContextType.Domain, ip, user, password))
{
GroupPrincipal group = GroupPrincipal.FindByIdentity(pc, groupname);
UserPrincipal up = UserPrincipal.FindByIdentity(pc, username);
group.Members.Add(up);
group.Save(); // here the exception is thrown
}