public void UpdateAdminPermissions(string userName, bool admin, bool export, bool canImpersonate) { bool isNewUser = true; AdminPermission newPermission = null; // Get the current permissions AdminPermissions permissions = ManagementServer.GetAdminPermissions(); // Check for existing permissions of the given user foreach (AdminPermission permission in permissions) { if (string.Compare(permission.UserName, userName, true) == 0) { isNewUser = false; newPermission = permission; break; } } // If it is a new user, add new permissions to the collection if (isNewUser) { newPermission = new AdminPermission(); newPermission.UserName = userName; permissions.Add(newPermission); } newPermission.Admin = admin; newPermission.Export = export; newPermission.CanImpersonate = canImpersonate; bool updated = ManagementServer.UpdateAdminUsers(permissions); }