/// <summary> /// Add <c>Role</c> to <c>System User</c>. /// <para> /// For more information look at https://msdn.microsoft.com/en-us/library/jj602982.aspx /// </para> /// </summary> /// <param name="userId"><c>System User</c> Id</param> /// <param name="roleId"><c>Role</c> Id. /// <para> /// You should provide organization related role Id. /// </para> /// </param> public void AddRole(Guid userId, Guid roleId) { ExceptionThrow.IfGuidEmpty(userId, "userId"); ExceptionThrow.IfGuidEmpty(roleId, "roleId"); EntityReferenceCollection entityReferenceCollection = new EntityReferenceCollection(); entityReferenceCollection.Add(new EntityReference("role", roleId)); CommonHelper commonHelper = new CommonHelper(this.OrganizationService); commonHelper.Associate(userId, this.EntityName, entityReferenceCollection, "systemuserroles_association"); }