"Attempted to perform an unauthorized operation" error: client side function

Application Error

 

Exception caught in: Epicor.Ice.Lib.RestClient

 

## Error Detail ##
============
##!Message:##! Attempted to perform an unauthorized operation.
##!Program:##! Epicor.Ice.Lib.RestClient.dll
##!Method:##! MoveNext

 

## Client Stack Trace ##
==================
   at Ice.Lib.RestClient.ResilientCaller.<InnerPostAsyncWithErrorHandling>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Ice.Lib.RestClient.ResilientCaller.<PostAsyncWithErrorHandling>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Ice.Lib.RestClient.AsyncToSyncHelper.DoSynchronous[TResult](Task`1 task)
   at Ice.Lib.RestClient.RestClient.Ice.Lib.RestClient.IRestFunctionCaller.Post(String library, String function, RestContent content, Boolean published)
   at Script.btnSelect_Click(Object sender, EventArgs args)
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at Infragistics.Win.Misc.UltraButtonBase.OnClick(EventArgs e)
   at Ice.Lib.Framework.EpiButton.OnClick(EventArgs e)
   at Infragistics.Win.Misc.UltraButton.OnMouseUp(MouseEventArgs e)
   at Ice.Lib.Framework.EpiButton.OnMouseUp(MouseEventArgs e)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

Visual Studio:

System.UnauthorizedAccessException
  HResult=0x80070005
  Message=Attempted to perform an unauthorized operation.
  Source=Epicor.Ice.Lib.RestClient
  StackTrace:
   at Ice.Lib.RestClient.ResilientCaller.<InnerPostAsyncWithErrorHandling>d__5.MoveNext()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Ice.Lib.RestClient.ResilientCaller.<PostAsyncWithErrorHandling>d__4.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Ice.Lib.RestClient.AsyncToSyncHelper.DoSynchronous[TResult](Task`1 task)
   at Ice.Lib.RestClient.RestClient.Ice.Lib.RestClient.IRestFunctionCaller.Post(String library, String function, RestContent content, Boolean published)
   at Script.btnSelect_Click(Object sender, EventArgs args) in c:\ProgramData\Epicor\dev01-808\3.2.600.0\JRF\CustomDLLs\App.Quotes_Parts.MainController.EP.Customization.Reverse Search.CustomCode.0.cs:line 386
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at Infragistics.Win.Misc.UltraButtonBase.OnClick(EventArgs e)
   at Ice.Lib.Framework.EpiButton.OnClick(EventArgs e)
   at Infragistics.Win.Misc.UltraButton.OnMouseUp(MouseEventArgs e)
   at Ice.Lib.Framework.EpiButton.OnMouseUp(MouseEventArgs e)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

  This exception was originally thrown at this call stack:
    [External Code]
    Script.btnSelect_Click(object, System.EventArgs) in App.Quotes_Parts.MainController.EP.Customization.Reverse Search.CustomCode.0.cs
    [External Code]

Is is working or not working on the same machine or different?
is the same sysconfig with thes same binding is used?
Is it possible that you run client with and without Run as administrator for this case?

It is not working on the same machine with different users. It does NOT fail for all users, just some. I also tried it with different users on different machines and same result

It is the same sysconfig/client and same bindings for each of these tests. The only difference is if I run as a different (known to fail) user, it fails.

The clients do not run as administrators, but I will verify this test as well.

We do use Windows binding btw, not sure it that’s helpful

Is it possible that there is no data for these users? For example, no records because of Territory security?

That is an interesting theory. I would think it would also fail at the REST API level using that users credentials if this were the case however, but I am not seeing that. Let me explore that

Well, i think this is the problem, RestClient uses Windows auth frpm session AFAIR, so not sure how are you trying to make it work with different users on the same machine

This doesn’t explain why it wouldn’t work for that users machine however, I would think?
So I first hear about this from the user who is using their machine (and logged in as such), so I would think the windows session would be totally kosher.

Only in the testing scenario am I running Epicor as the different users, but I am indeed able to replicate the failure by simply having those ā€œproblemā€ users attempt the test on their machine

try to set username binding in sysconfig for test

Ok let me attempt…

UsernameWindowsChannel or UsernameSSLChannel?

Wheteve you have free on the server.
I guess tcp is already used for Windows binding, so http will be fine for try

Shoot, it seems neither one is letting me in. Do I need to establish the binding on the EAC, I’m guessing?

THis is not production server, right :slight_smile: ?
yes, you use either EAC or just set it directly in web.config

haha correct. I’d like to set it in the web config so I can easily go back :wink:

Ok let me set it there…

search for protocolMapping in web.config
1 binding per protocol

1 Like

Should I do the HttpsOffloadBinaryUserNameChannel or the other one?
NVM I’m an idiot, disregard. the first is http

whe do you have now? net.tcp only? or https as well?

In any case, dont use Offload , it is only for SSL offloading on some indtermediary host, lke ARR and F5

so I would go with HttpsBinaryUsernameChannel
I assume you have https cert already installed as you use functions

add
<add scheme="https" binding="customBinding" bindingConfiguration="HttpsBinaryUsernameChannel" />

after <remove scheme="https" />

Ok I changed the web config and recycled IIS app pool for that. I should change my client config to not use Windows, but instead use HttpsBinaryWindowsChannel


image