CRM의 특정 레코드에 대한 액세스 권한을 검색하는 데 문제가 있습니다. 여기에 제안RetrievePrincipleAccess AccessRights는 항상 웹 API에서 null입니다. - Dynamics CRM 2016
나는 RetrievePrincipalAccess 웹 API 호출을 사용하고 있습니다 :
https://msdn.microsoft.com/en-us/library/mt683539.aspx
그러나, AccessRights를 필드는 항상 null입니다.
이것은 사용자가 시스템 관리자 나 보안 역할인지를 발생합니다.
var crmTesting = {
tests: {
getUserPrivilegesForRecord: function() {
var recordId = Xrm.Page.data.entity.getId().replace('{', '').replace('}', '');
var userId = Xrm.Page.context.getUserId().replace('{', '').replace('}', '');
console.log(recordId);
console.log(userId);
crmTesting.api.retrievePrincipalAccess(userId, 'accounts', recordId, function (r) {
console.log(r);
});
}
},
api: {
retrievePrincipalAccess: function (userId, entityPluralName, entityId, callback) {
if (!this.context.loaded) {
this.context.init();
}
var url = 'systemusers(' + userId
+ ")/Microsoft.Dynamics.CRM.RetrievePrincipalAccess([email protected])[email protected]={'@odata.id':'"
+ entityPluralName + '(' + entityId + ")'}";
this.get(url, callback);
},
get: function (url, callback, error) {
if (!this.context.loaded) {
this.context.init();
}
var xhr = new XMLHttpRequest();
xhr.open('GET', this.context.clientUrl + '/api/data/v8.1/' + url);
xhr.setRequestHeader('Accept', 'application/json');
xhr.setRequestHeader('Prefer', 'odata.include-annotation=OData.Community.Display.V1.FormattedValue');
xhr.setRequestHeader('OData-MaxVersion', '4.0');
xhr.setRequestHeader('OData-Version', '4.0');
xhr.onload = function() {
if (xhr.status == 200) {
if (typeof callback != 'undefined') {
var result = JSON.parse(xhr.responseText);
callback(result);
}
}
else if (xhr.status == 204) {
if (typeof callback != 'undefined') {
callback();
}
}
else {
console.error(xhr.responseText);
if (typeof error != 'undefined') {
error(xhr.responseText);
}
return;
}
};
xhr.send();
},
post: function (url, data, callback, error) {
if (!this.context.loaded) {
this.context.init();
}
var xhr = new XMLHttpRequest();
xhr.open('POST', this.context.clientUrl + '/api/data/v8.1/' + url);
xhr.setRequestHeader('Accept', 'application/json');
xhr.setRequestHeader('Context-Type', 'application/json; charset=utf-8');
xhr.setRequestHeader('OData-MaxVersion', '4.0');
xhr.setRequestHeader('OData-Version', '4.0');
xhr.onload = function() {
if (xhr.status == 200 || xhr.status == 204) {
try {
var response = JSON.parse(xhr.responseText);
if (typeof callback != 'undefined') {
callback(response);
}
}
catch (e) {
console.log('Request successful. No response.');
}
return;
}
else {
console.error(xhr.responseText);
if (typeof error != 'undefined') {
error(xhr.responseText);
}
}
};
if (typeof data == 'string') {
xhr.send(data);
}
else {
xhr.send(JSON.stringify(data));
}
},
context: {
loaded: false,
context: {},
clientUrl: '',
init: function() {
this.context = this.getContext();
this.clientUrl = this.context.getClientUrl();
this.loaded = true;
},
getContext: function() {
if (typeof GetGlobalContext != 'undefined') {
return GetGlobalContext();
}
else if (typeof Xrm != 'undefined') {
return Xrm.Page.context;
}
else {
throw new Error('Context is not available.');
}
}
}
}
};
어떤 도움 등이 많이 주시면 감사하겠습니다 일어나는 이유 :
여기 내 코드입니다.
Microsoft 버그인지 또는 내가 잘못한 것이 있는지 확인하여 여기에서 유효성을 검사하고 싶습니다.
내 요청 헤더 :
Accept:application/json
Accept-Encoding:gzip, deflate, sdch, br
Accept-Language:en-US,en;q=0.8
Cache-Control:no-cache
Connection:keep-alive
Cookie:<cookie>
Host:<domainurl>
OData-MaxVersion:4.0
OData-Version:4.0
Pragma:no-cache
Prefer:odata.include-annotation=OData.Community.Display.V1.FormattedValue
Referer:<crmorgurl>/form/ClientApiWrapper.aspx?ver=1916985412
User-Agent:Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36
그리고 내 응답 헤더 :
Cache-Control:no-cache
Content-Encoding:gzip
Content-Length:169
Content-Type:application/json; odata.metadata=minimal
Date:Wed, 24 May 2017 10:03:51 GMT
Expires:-1
OData-Version:4.0
Pragma:no-cache
REQ_ID:e5b24ef1-4531-4492-a251-dc9e7f91875e
Server:Microsoft-IIS/8.5
Vary:Accept-Encoding
X-AspNet-Version:4.0.30319
X-Powered-By:ASP.NET
쿼리 문자열 매개 변수 :
@tid:{'@odata.id':'accounts(C0988888-6EF4-E611-80FD-005056AC5406)'}
내가 DigitalFlow에서 xRM을-WebApi - 클라이언트 라이브러리를 사용하여 시도 그리고 같은 것을 얻었다.
요청 헤더 :
GET /<orgname>/api/data/v8.0/systemusers(F52C4FBB-E653-E611-80FB-005056AC5406)/Microsoft.Dynamics.CRM.RetrievePrincipalAccess([email protected])[email protected]={%[email protected]%22:%22accounts(06918888-6EF4-E611-80FD-005056AC5406)%22} HTTP/1.1
Host: <crmdomain>
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
OData-Version: 4.0
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36
Content-Type: application/json; charset=utf-8
Accept: application/json
If-None-Match: null
OData-MaxVersion: 4.0
Referer: <crmorgurl>/form/ClientApiWrapper.aspx?ver=1916985412
Accept-Encoding: gzip, deflate, sdch, br
Accept-Language: en-US,en;q=0.8
Cookie: <cookie>
응답 헤더를 :
HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Type: application/json; odata.metadata=minimal
Content-Encoding: gzip
Expires: -1
Vary: Accept-Encoding
Server: Microsoft-IIS/8.5
REQ_ID: 6981cbe8-1f66-42af-8227-bcd855c90ec7
OData-Version: 4.0
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Wed, 31 May 2017 11:57:20 GMT
Content-Length: 170
나는 운이없는 문제를 재현하려고 노력했다 (나는 항상 오류나 예상되는 응답을 얻는다). MSDN에서 AccessRights 속성은 nullable이 아니므로 조금 이상합니다. 요청 및 응답을 포함시켜주십시오. 감사! –
둘러보기 주셔서 감사합니다. 요청 및 응답 헤더를 추가했습니다. 처음에는이 요청이 8.2 버전에서만 가능하다고 생각 했었지만 릴리스 노트를 통해 8.0/8.1이라고 생각했습니다. 아주 이상한. – Asher
예, 어제는 8.0/8.1/8.2를 사용하여 시도했지만 모든 시나리오에서 작동했습니다. 나는 또 다른 모습을 취할 것이고, 내가 뭔가를 찾으면 알려 줄 것이다. –