Checking Access Permissions for Custom Class Operation Execution

Below is the example of using the SetCustomOb operation for checking access permissions of the current user for custom class object operation execution. The request contains moniker of custom class object and the operation, which executabilty must be checked. If the operation can be executed, the response returns object moniker; if the operation cannot be executed, the error is returned containing a reason of operation execution denial. The appropriate record is logged into access protocol.

SOAP request:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SetCustomOb xmlns="http://www.fsight.ru/PP.SOM.Som">
<tCustomOb xmlns="">
  <id>LDPFDGAHAHHCGOAEBAFLLHKHMOALEEDEMKDKCJAAKNELDHAE!M!S!TGHNHGJAHAHHCGOAENBPOBGJCGMEKKAFEILDEOPPCHPKFAHNO</id>
  </tCustomOb>
<tArg xmlns="">
<pattern>
  <obInst>true</obInst>
  <parsOwnDefVals>true</parsOwnDefVals>
<auditOp>
  <operationKey>1</operationKey>
  <comment>Check access permissions for operation execution: Import</comment>
  </auditOp>
  </pattern>
  <meta />
  </tArg>
  </SetCustomOb>
  </s:Body>
  </s:Envelope>

SOAP response:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<soapenv:Fault>
  <faultcode>soapenv:Sender</faultcode>
  <faultstring>Not enough rights to execute the 'Unknown operation' operation with the 'Data handler' (CUST_OBJ) object of the 'ADMIN' user</faultstring>
<detail>
<ExceptionDetail xmlns="http://schemas.datacontract.org/2004/07/System.ServiceModel" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <HelpLink xsi:nil="1" />
  <InnerException xsi:nil="1" />
  <Message>Not enough rights to execute the 'Unknown operation' operation with the 'Data handler' (CUST_OBJ) object of the 'ADMIN' user</Message>
  <StackTrace xsi:nil="1" />
  <Type>System.Exception</Type>
  </ExceptionDetail>
<Error>
  <Message>Not enough rights to execute the 'Unknown operation' operation with the 'Data handler' (CUST_OBJ) object of the 'ADMIN' user</Message>
  <Code>6374</Code>
  <PiClass>CPiObjException</PiClass>
  <PiState>AAAAAAEAAAAAAAAA5hgAAAsAAACBAAAAHQQ1BDQEPgRBBEIEMARCBD4ERwQ9BD4EIAA/BEAEMAQyBCAANAQ7BE8EIAAyBEsEPwQ+BDsEPQQ1BD0EOARPBCAAPgQ/BDUEQAQwBEYEOAQ4BCAAJwAdBDUEOAQ3BDIENQRBBEIEPQQwBE8EIAA+BD8ENQRABDAERgQ4BE8EJwAgAEEEIAA+BDEESgQ1BDoEQgQ+BDwEIAAnAB4EMQRABDAEMQQ+BEIERwQ4BDoEIAA0BDAEPQQ9BEsERQQnACAAKABDAFUAUwBUAF8ATwBCAEoAKQAgAEMEIAA/BD4EOwRMBDcEPgQyBDAEQgQ1BDsETwQgACcAQQBEAE0ASQBOACcACwAAACAAAAAuAC4AXABNAG8AZABcAEsAZQBTAG8AbQBcAFMAbwBtAFwAUwBvAG0ATQBlAHQAYQBiAGEAcwBlAC4AYwBwAHAAAAAAAFl0AAALAAAAAAAAAAsAAABeAAAAdgBvAGkAZAAgAF8AXwBjAGQAZQBjAGwAIABDAFMAbwBtAE0AZQB0AGEAYgBhAHMAZQA6ADoAQwBDAGgAZQBjAGsAQQBuAGQAQQB1AGQAaQB0ADoAOgBFAHIAcgBvAHIAKABjAG8AbgBzAHQAIABzAHQAcgB1AGMAdAAgAEMAUwBvAG0ATQBlAHQAYQBiAGEAcwBlADoAOgBDAEMAaABlAGMAawBSAGUAcwAgACYAKQAgAGMAbwBuAHMAdAALAAAAAAAAAAAAAAAAAAAAAwAAAA==</PiState>
  </Error>
  <Exception>Not enough rights to execute the 'Unknown operation' operation with the 'Data handler' (CUST_OBJ) object of the 'ADMIN' user</Exception>
  </detail>
  </soapenv:Fault>
  </soapenv:Body>
  </soapenv:Envelope>

JSON request:

{
"SetCustomOb" :
{
"tCustomOb" :
{
"id" : "LDPFDGAHAHHCGOAEBAFLLHKHMOALEEDEMKDKCJAAKNELDHAE!M!S!TGHNHGJAHAHHCGOAENBPOBGJCGMEKKAFEILDEOPPCHPKFAHNO"
},
"tArg" :
{
"pattern" :
{
"obInst" : "true",
"parsOwnDefVals" : "true",
"auditOp" :
{
"operationKey" : "1",
"comment" : "Check access permissions for operation execution: Import"
}
},
"meta" : ""
}
}
}

JSON response:

{
"Fault" :
{
"faultcode" : "soapenv:Sender",
"faultstring" : "Not enough rights to perform the 'Unknown operation' operation with the 'Data handler' (CUST_OBJ) object of the 'ADMIN' user",
"detail" :
{
"ExceptionDetail" :
{
"HelpLink" :
{
"@nil" : "1"
},
"InnerException" :
{
"@nil" : "1"
},
"Message" : "Not enough rights to perform the 'Unknown operation' operation with the 'Data handler' (CUST_OBJ) object of the 'ADMIN' user",
"StackTrace" :
{
"@nil" : "1"
},
"Type" : "System.Exception"
},
"Error" :
{
"Message" : "Not enough rights to perform the 'Unknown operation' operation with the 'Data handler' (CUST_OBJ) object of the 'ADMIN' user",
"Code" : "6374",
"PiClass" : "CPiObjException",
"PiState" : "AAAAAAEAAAAAAAAA5hgAAAsAAACBAAAAHQQ1BDQEPgRBBEIEMARCBD4ERwQ9BD4EIAA\/BEAEMAQyBCAANAQ7BE8EIAAyBEsEPwQ+BDsEPQQ1BD0EOARPBCAAPgQ\/BDUEQAQwBEYEOAQ4BCAAJwAdBDUEOAQ3BDIENQRBBEIEPQQwBE8EIAA+BD8ENQRABDAERgQ4BE8EJwAgAEEEIAA+BDEESgQ1BDoEQgQ+BDwEIAAnAB4EMQRABDAEMQQ+BEIERwQ4BDoEIAA0BDAEPQQ9BEsERQQnACAAKABDAFUAUwBUAF8ATwBCAEoAKQAgAEMEIAA\/BD4EOwRMBDcEPgQyBDAEQgQ1BDsETwQgACcAQQBEAE0ASQBOACcACwAAACAAAAAuAC4AXABNAG8AZABcAEsAZQBTAG8AbQBcAFMAbwBtAFwAUwBvAG0ATQBlAHQAYQBiAGEAcwBlAC4AYwBwAHAAAAAAAFl0AAALAAAAAAAAAAsAAABeAAAAdgBvAGkAZAAgAF8AXwBjAGQAZQBjAGwAIABDAFMAbwBtAE0AZQB0AGEAYgBhAHMAZQA6ADoAQwBDAGgAZQBjAGsAQQBuAGQAQQB1AGQAaQB0ADoAOgBFAHIAcgBvAHIAKABjAG8AbgBzAHQAIABzAHQAcgB1AGMAdAAgAEMAUwBvAG0ATQBlAHQAYQBiAGEAcwBlADoAOgBDAEMAaABlAGMAawBSAGUAcwAgACYAKQAgAGMAbwBuAHMAdAALAAAAAAAAAAAAAAAAAAAAAwAAAA=="
},
"Exception" : "Not enough rights to perform the 'Unknown operation' operation with the 'Data handler' (CUST_OBJ) object of the 'ADMIN' user"
}
}
}
public static bool SetCustomObCheckAndAudit(CustomObId moniker, CustomOperation operation)
{
var somClient = new SomPortTypeClient(); // Proxy object for operation execution
// Operation execution parameters
var tSet = new SetCustomOb()
{
tArg = new SetCustomObArg()
{
pattern = new CustomObMdPattern()
{
auditOp = new ObAuditOp()
{
operationKey = operation.k,
comment = "Check access permissions for operation execution: " + operation.n
}
},
meta = new CustomObMd()
},
tCustomOb = moniker
};
// Check operation execution access permissions
try
{
var result = somClient.SetCustomOb(tSet);
return true;
}
catch
{
return false;
}
}

See also:

SetCustomOb: Operation