Basically, proxy.GetPolicyByOperation("CreateSalesInvoice", context) is failing, not the actual CreateSalesInvoice() method. To double check, I removed all other code and executed only GetPolicyByOperation(). The authorization store is SQL Server DB.
There are two events in the event log of server. One difference I have noted here is Application and Scope key are null in the warning but they are present in Information.
--------Warning----------
Exception type:
System.ArgumentException
Exception message:
Value does not fall within the expected range.
SecurityContext:
ApplicationKey: null
ScopeKey: null
User: Domain\User
Action:
Get
Input parameters:
<RequestObjects>
<ApplicationKey xmlns:xsi="www.w3.org/.../XMLSchema-instance" xmlns:xsd="www.w3.org/.../XMLSchema">
<Id xmlns="schemas.microsoft.com/.../01">25cc1a21-2cc4-4b13-a1c8-eea186fb688a</Id>
</ApplicationKey></RequestObjects>
Stack Trace:
at Microsoft.Interop.Security.AzRoles.AzAuthorizationStoreClass.Initialize(Int32 lFlags, String bstrPolicyURL, Object varReserved)
at Microsoft.Dynamics.Security.AzManHelper.Initialize()
at Microsoft.Dynamics.Security.AzManHelper..ctor()
at Microsoft.Dynamics.Security.AzManHelper.GetInstance()
at Microsoft.Dynamics.Security.AzManApplicationServiceImplementation.RetrieveForGetByKey(SecurityContext context, Key key)
at Microsoft.Dynamics.Security.SecurityService.Get(SecurityContext context, Key key)
---------------------------
------Information-----------
Exception type:
Microsoft.Dynamics.Security.InvalidSecurityContextException
Exception message:
System.ArgumentException : Value does not fall within the expected range.
SecurityContext:
ApplicationKey: 25cc1a21-2cc4-4b13-a1c8-eea186fb688a
ScopeKey: 13
User: Domain\User
Action:
GetRoles
Input parameters:
<RequestObjects>
<string>Domain\User</string></RequestObjects>
Stack Trace:
at Microsoft.Dynamics.Security.ValidationHelper.ValidateContext(SecurityContext context)
at Microsoft.Dynamics.Security.AzManMemberAccess.GetRoles(SecurityContext context, String member)
------------------------------
Thanks,
Sai