public void UpdateGroupPrincipal(GroupPrincipal group) { if (this.SamAccountName != null) { group.SamAccountName = SetValueOrNull(this.SamAccountName); } if (this.Description != null) { group.Description = SetValueOrNull(this.Description); } if (this.IsSecurityGroup != null) { group.IsSecurityGroup = this.IsSecurityGroup; } if (this.Scope != null) { group.GroupScope = this.Scope; } // Get DistinguishedName from User or Group Identity for ManagedBy Property if (this.ManagedBy != null && group.GetUnderlyingObjectType() == typeof(DirectoryEntry)) { String distinguishedName = DirectoryServices.GetDistinguishedName(this.ManagedBy); if (distinguishedName == null) { distinguishedName = this.ManagedBy; // Cant' Find As User Or Group, Pass Raw Value (Might Be ~null~) } DirectoryServices.SetProperty((DirectoryEntry)group.GetUnderlyingObject(), "managedby", distinguishedName); } if (group.GetUnderlyingObjectType() == typeof(DirectoryEntry) && this.Properties?.Count > 0) { DirectoryServices.SetProperties((DirectoryEntry)group.GetUnderlyingObject(), this.Properties); } }