Option #1 - Writing code.
At the minimum you have to set the following required attributes for a new disabled user:Entity _disabledUser = new Entity("systemuser");
_disabledUser["firstname"] = "John";
_disabledUser["lastname"] = "Smith";
_disabledUser["issyncwithdirectory"] = false;
_disabledUser["isdisabled"] = true;
_disabledUser["internalemailaddress"] = "john.smith@fakemail.com";
_disabledUser["businessunitid"] = new EntityReference("businessunit", new Guid("7AFD896E-B3AD-E711-A967-000D3A192828"));
_disabledUser["domainname"] = "john.smith@fakedomain.com";
_service.Create(_disabledUser);
Note that the phantom domainname (User Name) must be unique and not to duplicate with any other existing enabled or disabled users. The internalemailaddress is allowed to be duplicated value when I run the above code.
This option requires making program, and could be quick to generate a few users. But when the legacy users run in the hundreds, a better option is to use a software utility to read the legacy user list and generate them on the destination Dynamics system, with just a push of a button. And no coding needed. I'm talking about option 2 next.
Option #2 - Integration software.
If you've done some Dynamics data migration and integration, you might hear of Kingswaysoft SSIS Integration Toolkit for Microsoft Dynamics 365. The toolkit comes with components that allow you to connect to the source and destination Dynamics CRM sites to read and write data records. Of course all the standard ETL components are available for your SSIS data transformation project. The Toolkit is free if you don't want to deploy to run automatically on schedule, which is fine here since producing disabled users is not something to do daily.Here's the snapshot of the data flow:
The Derived Columns component contains constant values for issyncwithdirectory, isdisabled, and businessunitid that will be used in the destination component for every disabled user record:
The rest of required user data will come from the source. So the destination field mappings will look like this:
Here I'm calling the Upsert action on the systemuser entity. Create action would be more optimal.
Hope this helps with your Dynamics 365/CRM migration project. I'm sure there are other options. The SSIS Integration Toolkit from Kingswaysoft really helps jump start my project with so many legacy users in the old CRM system.