IsCurrentUserAdmin API method throwing Exception

  • 5 August 2019
  • 1 reply
  • 4 views

Hi,

 

We are using below code to determine if the current user is admin in K2 or not.

 

System.Security.Principal.WindowsIdentity oUser = System.Security.Principal.WindowsIdentity.GetCurrent();
objErrorLogs.LogAction("Current logged in user name:" + oUser.Name.ToUpper());
string UserName = System.Web.HttpContext.Current.User.Identity.Name.ToString();

objErrorLogs.LogAction("Current logged as per http context:" + UserName.ToUpper());
SourceCode.Workflow.Management.WorkflowManagementServer wms = new SourceCode.Workflow.Management.WorkflowManagementServer(sServer, 5555);


using (wms.Connection)
{
wms.Open();
if (wms.IsCurrentUserAdmin())
return true;

}

 

95% of the time the above code works fine. But randomly 5 to 6% of the time, K2 API IsCurrentUserAdmin() throws the following exception

 

Primary Credentials Not Authenticated. Session Not Authenticated.
at SourceCode.Hosting.Client.BaseAPI.BaseAPIConnection.RemoteCall(String TypeName, String MethodName, Object[] Parameters, Boolean[] NullList, MarshalMessageType CallType) at SourceCode.Workflow.Management.WorkflowManagementServer.IsCurrentUserAdmin() at HBMeU_Services.SharedServices.WorkflowEngine.WorkFlowCore.GetUserPermission(Int32 ProcessID, String ProcessName)
 

Although we are geting the correct current logged in username when we call .Net API System.Web.HttpContext.Current.User.Identity.Name but somehow K2 is throwing the above exception randomly few times.

 

We have configure kerberos and ADFS in our environment.


1 reply

Greetings   @farazhs


 


Not familiar with this but It could be a user account  cache issue or an oauth tokem issue given the Intermittent  occurance. Try clearing the cache, or perhaps rebooting the server can prevent the error.

Reply