Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

SAP .Net Connector 3.0 issue when using different SNC Libraries

arnd_gohr
Discoverer
0 Kudos

Hi all,

I have the following issue.
Within a C# program I need to connect to multiple systems using SNC / SSO. This is no problem if all systems are using the same SNC library. But if I need to connect to systems that are using different library, the .Net Connector always use the SNC library that was used for the first connection and not the library that is set in the RFCConfigParameters.

I’m not talking about a general connection issue! I only have an issue if I need to use different SNC libraries in one program

Environment:

SAP .Net Connector 3.0 issue when using different SNC Libraries

System 1 is using the legacy gx64krb5.dll SNC library
System 2 is using the sapcrypto.dll SNC library
Nco version: 3.0.20.0
See the following simplified example code:

//Connection Parameter
    public class SystemConfig : IDestinationConfiguration
    {
        public RfcConfigParameters GetParameters(String SystemName)
        {
            if ("system-1".Equals(SystemName))  //Using SNC LIB gx64krb5.dll        
            {
                RfcConfigParameters parms = new RfcConfigParameters();
                parms.Add(RfcConfigParameters.MessageServerHost, "system1");
                parms.Add(RfcConfigParameters.MessageServerService, "3610");
                parms.Add(RfcConfigParameters.LogonGroup, "PUBLIC");
                parms.Add(RfcConfigParameters.SystemID, "SY1");
                parms.Add(RfcConfigParameters.User, "UserName");
                parms.Add(RfcConfigParameters.Client, "100");
                parms.Add(RfcConfigParameters.Language, "en");
                parms.Add(RfcConfigParameters.SncMode, "1");
                parms.Add(RfcConfigParameters.SncLibraryPath, @"gx64krb5.dll");
                return parms;
            }
            if ("system-2".Equals(SystemName)) //Using SNC LIB sapcrypto.dll 
            {
                RfcConfigParameters parms = new RfcConfigParameters();
                parms.Add(RfcConfigParameters.MessageServerHost, " system2");
                parms.Add(RfcConfigParameters.MessageServerService, "3610");
                parms.Add(RfcConfigParameters.LogonGroup, "PUBLIC");
                parms.Add(RfcConfigParameters.SystemID, "SY2");
                parms.Add(RfcConfigParameters.User, "UserName");
                parms.Add(RfcConfigParameters.Client, "100");
                parms.Add(RfcConfigParameters.Language, "en");
                parms.Add(RfcConfigParameters.SncMode, "1");
                parms.Add(RfcConfigParameters.SncLibraryPath, @"C:\Program Files\SAP\FrontEnd\SecureLogin\lib\sapcrypto.dll");
                return parms;
            }
            else return null;
        } 
        public bool ChangeEventsSupported()
        {
            return true;
        }
        public event RfcDestinationManager.ConfigurationChangeHandler ConfigurationChanged;           
}    
//Connect to system1 using gx64krb5.dll and then to system2 using sapcrypto.dll
private void TestConnection()
{
        //Register configuration
        RfcDestinationManager.RegisterDestinationConfiguration(new SystemConfig());
        //Create destination for system 1 that use SNC LIB gx64krb5.dll
        RfcDestination destination1 = RfcDestinationManager.GetDestination("system-1");
        //Create destination for system 2 that use SNC LIB sapcrypto
        RfcDestination destination2 = RfcDestinationManager.GetDestination("system-2");
       destination1.Ping(); //Works fine
       destination2.Ping(); //Exception: SNCERR_UNKNOWN_MECH --> Using SNC_LIB from destination1
 }

I get a 'SNCERR_UNKNOWN_MECH' exception if I try to ping destination2 because the .Net Connector is still using the gx64krb5.dll SNC library from the first connection and not the library, that is configured in the RfcConfigParameters (sapcrypto.dll).

If I swap the ‘destination ping’ order and first ping destination 2, the connection to system2 works fine and I get a ‘GSS-API(maj): An invalid name was supplied’ exception if I try to connect to system1.

I already tried to ‘Unregister’ and ‘re-Register’ the destination configuration with no change.
I also run into the same issue with custom destinations.

Not sure if there is a way to completely reload the .Net Connector during the runtime before I try to connect to the 2nd system.

I know that this is a very special case and I’m not sure if someone else run into a similar issue. I’m more then happy for any ideas.

Thanks

0 REPLIES 0