I'm trying to rename a group. My code looks like the following
PrincipalContext context = new PrincipalContext(ContextType.Machine);
GroupPrincipal group = GroupPrincipal.FindByIdentity(context, "GroupName");
group.SamAccountName = "NewGroupName";
group.DisplayName = "NewGroupName";
group.Name = "NewGroupName";
group.Save();
The problem is that it crashes at group.DisplayName = "NewGroupName";
and throws the exception
property is not valid for this store type.
If I comment out that line the code will run on but I would like to change the Display name. I did some research and found this. However I am using Framework 4.0. Does anyone know another what to do this or am I going about this the wrong way?