0
votes

I have Created an User with a Business Unit for Dynamics 365 through .net core console application. But wondering how to create license for that user from the console application.

I have tried to insert values for License related fields in systemuser entity manually

public  static Guid CreateUsers(IOrganizationService _orgService, Dynamics365_User dynamics365_User)
        {

           Entity systemuser = new Entity("systemuser");           
            systemuser.Attributes.Add("domainname", dynamics365_User.domainname);
            systemuser.Attributes.Add("firstname", dynamics365_User.firstname);
            systemuser.Attributes.Add("lastname", dynamics365_User.lastname);
            systemuser.Attributes.Add("internalemailaddress", dynamics365_User.internalemailaddress);
            systemuser.Attributes.Add("isdisabled", dynamics365_User.isdisabled);

            //systemuser.Attributes.Add("islicensed", dynamics365_User.islicensed);
            systemuser.Attributes.Add("userlicensetype", dynamics365_User.userlicensetype);
            systemuser.Attributes.Add("caltype", new OptionSetValue(Convert.ToInt32(dynamics365_User.CalType)));
            //systemuser.Attributes.Add("applicationid", Guid.Parse("b28eba1a-bc54-408d-bc45-ddaa44f6918f"));
            //systemuser.Attributes.Add("applicationid", Guid.Parse("c4c6b5e8-050a-4bc0-a419-79e55345f751"));
            //systemuser.Attributes.Add("applicationid", new Guid("80af87d0-db9c-48b6-b561-9c75ec8489f0"));
            //systemuser.Attributes.Add("azureactivedirectoryobjectid", new Guid());

            systemuser.Attributes.Add("businessunitid", new EntityReference
            {
                Id = dynamics365_User.businessunit.Id,
                LogicalName = dynamics365_User.businessunit.LogicalName,
                Name = dynamics365_User.businessunit.Name
            });             
                Guid userid = _orgService.Create(systemuser);

 dynamics365_User.firstname, dynamics365_User.lastname, conn.OrganizationServiceProxy,ref temp);

            return userid;
        }
1
Have you assigned a license through .Net?Sameer Shinde

1 Answers

2
votes

I assume you are using On-Line as you mentioned Dynamice 365.

  1. To activate User you need license for that particular user.
  2. You would need to have that particualr user already availble or newly created in Office 365.
  3. Once you have that user in Office 365 you could assign the user License.
  4. After assigning license you will need to provide proper security role and business unit.

Youtube link: https://www.youtube.com/watch?v=kNRCAYiTrjA&feature=youtu.be

There are different ways you could create new user in Office 365.

To add multiple users at the same time, follow these steps:

  1. Use a spreadsheet to add people in bulk. See Add several users at the same time.
  2. Automate adding accounts and assigning licenses. See Create user accounts with Office 365 PowerShell. Choose this method if you're already familiar with using Windows PowerShell cmdlets.
  3. Using ActiveDirectory? Set up directory synchronization for Office 365. Use the Azure AD Connect tool to replicate Active Directory user accounts (and other Active Directory objects) in Office 365. The sync only adds the user accounts. You will need to assign licenses to the synced users before they can use email and other Office apps.
  4. Migrating from Exchange? Ways to migrate multiple email accounts to Office 365. When you migrate multiple mailboxes to Office 365 by using either cutover, staged, or a hybrid Exchange method, you will add users automatically as part of the migration. The migration only adds the user accounts. You will need assign licenses to the users before they can use email and other Office apps.

Ref from Microsoft Docs: https://docs.microsoft.com/en-us/office365/admin/add-users/add-users?redirectSourcePath=%252fen-US%252fArticle%252fCreate-or-edit-users-in-Office-365-1970f7d6-03b5-442f-b385-5880b9c256ec&view=o365-worldwide