/// <summary>
/// 添加角色,删除角色
/// </summary>
public void UpdateRole(IOrganizationService service,Guid userId)
{
//关系
Relationship ship = new Relationship("systemuserroles_association");
//角色集合
EntityReferenceCollection roleCellection = new EntityReferenceCollection();
roleCellection.Add(new EntityReference()
{
LogicalName = "role",
Id = new Guid("CA1DED1E-62A3-420B-A101-001B84716206")
});
roleCellection.Add(new EntityReference()
{
LogicalName = "role",
Id = new Guid("DEED80B6-BD37-42E2-BD5C-0011ED0F191A")
});
//分配权限
service.Associate("systemuser", userId, ship, roleCellection);
//删除权限
service.Disassociate("systemuser", userId, ship, roleCellection);
}
/// 添加角色,删除角色
/// </summary>
public void UpdateRole(IOrganizationService service,Guid userId)
{
//关系
Relationship ship = new Relationship("systemuserroles_association");
//角色集合
EntityReferenceCollection roleCellection = new EntityReferenceCollection();
roleCellection.Add(new EntityReference()
{
LogicalName = "role",
Id = new Guid("CA1DED1E-62A3-420B-A101-001B84716206")
});
roleCellection.Add(new EntityReference()
{
LogicalName = "role",
Id = new Guid("DEED80B6-BD37-42E2-BD5C-0011ED0F191A")
});
//分配权限
service.Associate("systemuser", userId, ship, roleCellection);
//删除权限
service.Disassociate("systemuser", userId, ship, roleCellection);
}