cancel
Showing results for 
Search instead for 
Did you mean: 

How to login to SAP using RFC user credentials

Former Member
0 Kudos

  Hi,

  I usually login to SAP from my .net application by creating an instance of SAP Logon control and passing the credentials(dialogue user credentials).

                tObjType = Type.GetTypeFromProgID("SAP.LogonControl.1");                

                oLoginCtrl = Activator.CreateInstance(tObjType);

But now I have a scenario like the customer wants my application to use RFC user credentials which will not work if I use SAP Logon control.

Is there any other way to login to SAP using RFC credentials?


Thanks in advance


language: C#

framework:4.0

VS: 2010

OS:Windows 7


Regards,

Manosh Jacob

Accepted Solutions (1)

Accepted Solutions (1)

hynek_petrak
Active Participant
0 Kudos

Hi Manosh,

I have on hand just the VB code below. For C#, however, the idea shall be obvious... Instead of "SAP.Functions.Unicode" you may use also "SAP.Functions" if you do not expect issues with code pages.


Set r3 = CreateObject("SAP.Functions.Unicode")

  r3.Connection.ApplicationServer = "server.ip"

  r3.Connection.SystemNumber = "00" ' Put your system number

  r3.Connection.User = "Username"

  r3.Connection.Password = "Password"

  r3.Connection.Client = "010" ' Put your client number

 

  r3.Connection.Language = "EN"

 

Dim silent As Boolean

silent = True

' Put silent = False if you want a password pop up for debugging

  If r3.Connection.Logon(0, silent)  Then

     Set func = r3.Add("BAPI_FUNCTION")

     func.Call

  End If

Answers (1)

Answers (1)

hynek_petrak
Active Participant
0 Kudos

Btw. for new application I recommend to switch over to .NET Connector. In the end it's much simpler to use and you can get much more out of it. And it's managed code.

Former Member
0 Kudos

Hi,

Thank you very much Hynek Petrak. It worked for me. I am pasting my code here.

tObjType = Type.GetTypeFromProgID("SAP.Functions");

oLoginCtrl = Activator.CreateInstance(tObjType);

_oSAPCon = oLoginCtrl.GetType().InvokeMember("Connection", BindingFlags.InvokeMethod, null, oLoginCtrl, null);

I have been trying .NET Connector for a while. I will move to the same soon.

Sorry I took a little time to get back.

Regards,

Manosh Jacob

Former Member
0 Kudos

Hi

Thank you  Hynek Petrak,

Switch over to .NET Connector means SAP Netweaver Gateway ?

Regards

Manosh

MarkusTolksdorf
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello Manosh,

no, it means to switch over what is described in the blog located here:

http://scn.sap.com/people/thomas.weiss/blog/2011/01/14/a-spotlight-on-the-new-net-connector-30

Best regards,

Markus