I have a .Net application which use to create SAP sales orders through it. When I use a (common)single SAP user id to login to the rfcDestination it works perfectly. but it doesnt work with concurrent logins with different user id's. i see 2 case:
1) when i have logged in using a user id say test1(SAP user) it connects successfully.
2)when i login with different user and with incorrect password , it still connects.
I do not want to unregister test1 session as i want concurrent logins at same time. How do i achieve this. Below is the code i have tried so far
SAPConnection objDestConfig = new SAPConnection();
objDestConfig.AddOrEditDestination(appserver, Name, instanceno, systemid, txt_user.Text,
txt_password.Text, client, "E");
RfcDestination prd = RfcDestinationManager.TryGetDestination(Name);
if (prd == null)
{
RfcDestinationManager.RegisterDestinationConfiguration(objDestConfig);
prd = RfcDestinationManager.GetDestination(Name);
}
// }
//Establishing connection with SAP system
// RfcDestination dest = RfcDestinationManager.GetDestination(Name);
prd.Ping(); //always returns true even for incorrect password if the destination is registered.
public SAPConnection()
{
//check for available SAP destinations
availableDestinations = new Dictionary<string, RfcConfigParameters>();
}
public RfcConfigParameters GetParameters(string destinationName)
{
//reading current SAP destination configurations
RfcConfigParameters foundDestination;
availableDestinations.TryGetValue(destinationName, out foundDestination);
return foundDestination;
}
public bool ChangeEventsSupported()
{
return true;
}
public event RfcDestinationManager.ConfigurationChangeHandler ConfigurationChanged
{
add
{
changeHandler = value;
}
remove
{
}
}
//removes the destination that is known under the given name
public void RemoveDestination(string name)
{
if (name != null && availableDestinations.Remove(name))
{
changeHandler(name, new RfcConfigurationEventArgs(RfcConfigParameters.EventType.DELETED));
}
}
//allows adding or modifying a SAP destination for a specific application server
public void AddOrEditDestination(string appserver, string name, string systemnumber, string systemid, string user, string password, string client, string language)
{
RfcConfigParameters parameters = new RfcConfigParameters();
parameters[RfcConfigParameters.Name] = name;
parameters[RfcConfigParameters.User] = user;
parameters[RfcConfigParameters.Password] = password;
parameters[RfcConfigParameters.Client] = client;
parameters[RfcConfigParameters.Language] = language;
parameters[RfcConfigParameters.AppServerHost] = appserver;
parameters[RfcConfigParameters.SystemNumber] = systemnumber;
parameters[RfcConfigParameters.SystemID] = systemid;
RfcConfigParameters existingConfiguration;
if (availableDestinations.TryGetValue(name, out existingConfiguration))
{
//modifying SAP destination
//if a destination of that name existed before, we need to fire a change event
availableDestinations[name] = parameters;
RfcConfigurationEventArgs eventArgs = new RfcConfigurationEventArgs(RfcConfigParameters.EventType.CHANGED, parameters);
changeHandler(name, eventArgs);
}
else
{
//adding new SAP destination
availableDestinations[name] = parameters;
}