我正在尝试提取分配给系统用户的所有角色。我想我需要使用关联实体,但我不确定我应该如何继续使用该方法。这是我的代码片段:
Uri organizationUri = new Uri(this.ConnectionString);
Uri homeRealmUri = null;
ClientCredentials credentials = new ClientCredentials();
credentials.UserName.UserName = ConfigUserName;
credentials.UserName.Password = ConfigPassword;
Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy orgProxy = new Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy(organizationUri, homeRealmUri, credentials, null);
IOrganizationService _service = (IOrganizationService)orgProxy;
Microsoft.Xrm.Sdk.Entity account = new Microsoft.Xrm.Sdk.Entity("systemuser");
QueryExpression query = new QueryExpression
{
EntityName = account.LogicalName,
ColumnSet = new ColumnSet(true)
};
DataCollection<Microsoft.Xrm.Sdk.Entity> users = _service.RetrieveMultiple(query).Entities;
// fetch assigned roles of users