I need to revisit this. The script has been perfect as long as the changes are being made via the webpage. I am having issue with this business rule and modifying user membership via the Adaxes powershell tools. Right now, I was setting up a after creation user business rule where if the new user attribute employeeType = Consultant then put them into a group, then set that group as the primarygroup, and then remove from the Domain Users group. I receive the following error
 'INT Employee Tpe Rules': Add 'Capt Kirk (alloweddomain.com\\CCG Users)' to 'NoRights (alloweddomain.com\\Security Groups)'  
  Business Rules: Command Processor 'Business Rules' threw an exception when processing the command. A list of actions to be triggered by Business Rules couldn't be generated. Failed to check the following condition of the 'JV Group Access' business rule: If script 'Check for JV domain membership' returns true. Exception calling "GetObjectDomain" with "1" argument(s): "DN '<GUID=d891d948-b77e-4704-8d9e-5e264fe2281d>' is invalid.".
The business rule is using the script provided in this thread unchanged except to insert the disalloweddomain. I used the steps provided here Set user primary group to create the business rule to change the primary group.  
I also have the problem when using the Adaxes powershell to modify group memberships and indicating the -adaxesservice switch  
PS C:\\Windows\\system32> add-admgroupmember "this group" -member "CN=This User,OU=These Users,DC=alloweddomain,DC=com" -adaxesservice adaxesserver.alloweddomain.com  
add-admgroupmember : Command Processor 'Business Rules' threw an exception when processing the command.  
A list of actions to be triggered by Business Rules couldn't be generated.  
Failed to check the following condition of the 'JV Group Access' business rule: If script 'Check for JV domain membership' returns true.  
Exception calling "GetObjectDomain" with "1" argument(s): "DN '<SID=010500000000000515000000A5209E86A7B2F4A42B877F0E0C940000' is invalid.".  
At line:1 char:1  
+ add-admgroupmember "this group" -member "CN=This User,OU=These ...  
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
 + CategoryInfo : NotSpecified: (:) \[Add-AdmGroupMember\], DirectoryComException  
 + FullyQualifiedErrorId : Softerra.Adaxes.PowerShellModule.Commands.SetAdmGroupMemberCommandExecutor:ProcessRecord,Softerra.Adaxes.PowerShellModule.Commands.AddAdmGroupMemberCommand
This script has been great in maintaining our policy about the disalloweddomain members and I am hoping that this is an easy fix.  
Thanks in advance