Without seeing your code, it is hard to know for sure, but it sounds like you're almost there! I had a similar task a few years ago and this blog article was very helpful to me. This Scripting Guy article talks about the steps in a little more detail.
I don't know if you can do this with System.DirectoryServices.AccountManagement stuff. Microsoft made some common AD tasks easier with that namespace, but I'd be surprised if this was one of them.
With regards to removing the "Domain Users" group assignment, that is not possible until the primary group has been changed.
This is untested pseudo-code, but I think something like this will work.
// get the group
DirectoryEntry groupToAdd = new DirectoryEntry("LDAP://" + groupDistinguishedName);
// add the member
groupToAdd.Properties["member"].Add(userDistinguishedName);
// commit and close
groupToAdd.CommitChanges();
groupToAdd.Close();
You said you already know how to assign the primary group, so once you've done that and committed it, you can remove the "Domain Users" membership.
//Get the domain users
DirectoryEntry domainUsers = new DirectoryEntry("LDAP://" + domainUserDistinguishedName);
// Remove the user from the domain user group
domainUsers.Properties["member"].Remove(userDistinguishedName);
//Commit the changes
domainUsers.CommitChanges();
domainUsers.Close();
For reference, here's a nice AD in C# overview. Hope this helps!