Dear Team,
Below Issue facing in Epicor ERP Version 10.2.100.9
We have a running Epicor Single Sign on environment where epicor SSO functionality is working fine.
I am trying to run single sign on code of Epicor using one Web Project.
Below is simple code for understanding.
I did following things to achive this.
-
Created web project and fetched the windows user Login name and Domain name on default page => Page load event and written below code in it.
SSO ObjSSO = new SSO();
ObjSSO.ValidateUser(AppSrvUrl, out IsSSOUser, out UserId);a) AppSrvUrl = is URL value set in Epicor Administration Console for epicor SingleSignOn application
b) SSO is a class created in other class library project. Please refer point 2 for that. -
Created one reference dll project and added Ice.Lib.Logon.dll reference and few more required dll in it.
Seperate class library project required because Ice.Lib.Logon.dll required System.Windows.Form reference in project.In this dll ValidateUser method is created and inside that below code is written.
public void ValidateUser(string serverUrl, out Boolean isSSOUser, out string userId)
{
try
{
using (var session = LogOn.RunDialog(“MyLogon”, serverUrl, Session.LicenseType.WebService))
{
bool IsValidSession = session.IsValidSession(session.SessionID, session.UserID);
if IsValidSession == true)
{
isSSOUser = true;
userId = session.UserID;
}
else
{
isSSOUser = false;
userId = string.Empty;
}
}
}
catch(Exception ex)
{
ObjEvent.ExceptionEvent(“ValidateUser”, LogMsg.ToString(), ex);
isSSOUser = false;
userId = string.Empty;
}
}
Above things are working fine when testing the code during debugging using Visual Studio.
But once we host the project in IIS in Epicor application server, code Logon.Rundialog throwing exception.
i.e.startIndex cannot be larger than length of string.
I manage to reach in code of Ice.Lib.Logon.dll and found in it’s code logic below code is written
foreach (string commandLineArg in Environment.GetCommandLineArgs())
{
if (commandLineArg.Substring(1).ToLower() == “hh”)
{
flag = true;
break;
}
}
where one of commandLineArg value is blank and due to that we are getting above mention error.
Above code line I have implemented in my code to check what are the commandLineArg values are coming.
public void ValidateUser(string serverUrl, out Boolean isSSOUser, out string userId)
{
try
{
foreach (string commandLineArg in Environment.GetCommandLineArgs())
{
LogMsg.AppendLine("commandLineArg : " + commandLineArg);
if (commandLineArg.Substring(1).ToLower() == "hh")
{
flag = true;
break;
}
}
using (var session = LogOn.RunDialog("MyLogon", serverUrl, Session.LicenseType.WebService))
{
bool IsValidSession = session.IsValidSession(session.SessionID, session.UserID);
if IsValidSession == true)
{
isSSOUser = true;
userId = session.UserID;
}
else
{
isSSOUser = false;
userId = string.Empty;
}
}
}
catch(Exception ex)
{
isSSOUser = false;
userId = string.Empty;
ObjEvent.ExceptionEvent("ValidateUser", LogMsg.ToString(), ex);
}
}
After hosting found below result.
commandLineArg : c:\windows\system32\inetsrv\w3wp.exe
commandLineArg : -ap
commandLineArg : ERP10
commandLineArg : -v
commandLineArg : v4.0
commandLineArg : -l
commandLineArg : webengine4.dll
commandLineArg : -a
commandLineArg : \.\pipe\iisipm801c2a40-887b-4140-94e6-cc627fb6947f
commandLineArg : -h
commandLineArg : C:\inetpub\temp\apppools\ERP10\ERP10.config
commandLineArg : -w
commandLineArg :
you can find the argument -w is having blank value in next row and this is the cause of issue.
Looking for solution to know why -w is not having value and what need to do to resolve this.