// Retrieve the security groups of user JDOEILionReposSecurityUsersecurityUser=security.FindUserByName("JDOE");securityUser.LoadGroups(repos);// Add all the current security groups of user JDOE to a new userILionReposSecurityUserdefaultUser=security.AddUser("DefaultDeveloper");foreach(ILionReposSecurityGroupGroupinsecurityUser.Groups){defaultUser.AddGroup(Group);}defaultUser.SaveGroups(repos);// Clear all the current security groups of user JDOE and add the user to the DevOps security groupsecurityUser.ClearGroups();securityUser.AddGroup(securityGroup);securityUser.SaveGroups(repos);
PowerShell
# Retrieve the security groups of user JDOE$O_SecurityUser=$O_Security.FindUserByName("JDOE")$O_SecurityUser.LoadGroups($O_Repos)# Add all the current security groups of user JDOE to a new user$O_DefaultUser=$O_Security.AddUser("DefaultDeveloper")foreach($Groupin$O_SecurityUser.Groups){$O_DefaultUser.AddGroup($Group)}$O_DefaultUser.SaveGroups($O_Repos)# Clear all the current security groups of user JDOE and add the user to the DevOps security group$O_SecurityUser.ClearGroups()$O_SecurityUser.AddGroup($O_SecurityGroup)$O_SecurityUser.SaveGroups($O_Repos)