cancel
Showing results for 
Search instead for 
Did you mean: 

SAP Hana Anonymous User? And HTTP POST method?

Former Member
0 Kudos

Hi,

I currently would like to use anonymous user. But how do I go about setting up a SQLCC entry and embed a user name and password in their which will be used by the anonymous service. I would like end user to have anonymous authentication to hana server, but the final data that is retrieved is from an Odata service. Could you direct me as to how to go about the whole thing.

Also, currently in SAP Hana the http method defined is GET, for POST method it displays 405 Method Not Allowed error. How to configure http to accept post method.

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi everyone,

I had the same requirement as Aisha, where I had to provide anonymous access to an Odata service I had created. Going through this post, the solution for this exact requirement is not quite apparent. Therefore, I present the solution as shown below. I have combined the steps and solutions provided by others in this thread.

1. Create a .xssqlcc file ... Say anonuser.xssqlcc

{

  "description" : "Anon SQL connection"

}

2. Create a .xsjs file, reference the .xssqlcc file in getConnection() ...


 

var conn = $.db.getConnection("hana_hello::anonuser");


 

Which means only the above line should be in the .xsjs file.


 

3. Create a .xsaccess file, if not already created, with authentication = null, along with the anonymous connection statement ...

{

  "exposed" : true,

  "authentication" : null

  "anonymous_connection": "yourpackage::anonuser",

}

4. Finally, update the "_SYS_XS"."SQL_CONNECTIONS" table. Set the username to someone that has access to the database you are trying to call. This should happen in the SQLCC application, but it doesn't seem to work ... this is the code that is in that application.  Run the SQL command ...

UPDATE "_SYS_XS"."SQL_CONNECTIONS" SET username = '<database_user>' WHERE name = 'hana_hello::anonuser';


 

Preferably, use Thomas Jung's method to perform the above step, but if you don't have admin privileges, then the above SQL statement works fine.


Regards,

Rolan Carlo

Former Member
0 Kudos

Hi Rolan,

I tried the above steps in my HCP trial acount, in which I had created a odata service.

I have .xsodata file

service {

  "SYSTEM"."tablename" as "name" key generate local "GEN_ID";

}

, .xsaccess file with content that you mentioned.

.xssqlcc with description you mentioned.

.xsprivileges with content

{

    "privileges" : [ {

  "name" : "Basic",

  "description" : "Basic IoT MMS privilege"

  } ]

}

Also I created a new .xsjs file with


var conn = $.db.getConnection("hana_hello::anonuser");


And then I updated the "_SYS_XS"."SQL_CONNECTIONS" table

with UPDATE "_SYS_XS"."SQL_CONNECTIONS" SET username = '<database_user>' WHERE name = 'hana_hello::anonuser';


Everything was saved successfully.


But just when I try to access the odata from any browser, I get HTTP 500 error.


What could be going wrong?


BR

Suraj Nair

Former Member
0 Kudos

Hi Suraj,

You need to replace 'hana_hello' with the package name that contains your .xssqlcc file.

Also when you run the UPDATE statement, <database_user> is to be replaced with your user.

i.e., if you are using SYSTEM user and your package is named 'ODataService' then your statement should look something like this:

UPDATE "_SYS_XS"."SQL_CONNECTIONS" SET username = 'SYSTEM' WHERE name = 'ODataService::anonuser';


Regards,

Rolan A. Carlo

Former Member
0 Kudos

Hi Rolan,

Yes. I had done those changes.

But I haven't been able to go deep into it, as it has been decided to keep the authentication for now.

If we plan to use without authentication in future, then I will check those again, and if incase I get stuck, will open a open thread.

Thanks for the help

BR

SN

0 Kudos

Hi Aisha.

For this problem the better solution is:

1. We need create the file .xsaccess with the next instruction:

{

"exposed" : true,

"authentication" : null,

"anonymous_connection":"PackageName::Anonymous_Access"

}

2. Create the file Anonymous_Access.xssqlcc with the next instruction:

{

"description" : "Anonymous SQL connection for ..."

}

3. Like our friend Micheal, in the .xsjs file, reference the .xssqlcc file in getConnection() ...

var conn = $.db.getConnection("packagename::Anonymous_Access");

4. Enter in the link http://yourhanaserver:80instance/sap/hana/xs/admin/ - Access into XS Administration Page.

5. Search your package and the file Anonymous_Access.xssqlcc, and select it.

6. Intruduce the username and save.

I hope this help you.

johnson_wong
Member
0 Kudos

Expanding on Michael's answer, if you are trying to access an OData service (ie. not using XS code to access the data), you can set the "anonymous_connection" param in your .xsaccess file to the xssqlcc you've created.

The final .xsaccess file may look something like this:

{

    "anonymous_connection": "yourpackage::anonuser",

    "authentication" : null,

    "exposed": true

}

Assuming you also have an odata service defined via svc.xsodata, you can then access it with no authentication.

Ex.

http://yourserver:8000/yourpackage/svc.xsodata

Former Member
0 Kudos

Thanks ! This saved me.

    "anonymous_connection": "yourpackage::anonuser",

0 Kudos

Hi Johnson,

Your reply was really helpful. I am working with oData services and your reply just helped me a lot.

I was getting 403 forbidden error now that is resolved. I am able to get data using my odata service.

But when I am trying to post data using Postman i am getting 503 service unavailable error. I am able to get data in the postman but not post.

If you could help me?

Thanks in advance.

regards,

Animesh Ghosh

Former Member
0 Kudos

I found the answer ... well Jon found the answer ,,,

To allow the service to be accessed anonymously ...

1. Add a .xsaccess file with authentication = null ...

{

  "exposed" : true,

  "authentication" : null

}

2. Create a .xssqlcc file ... I called it anonuser.xssqlcc

{

  "description" : "Anon SQL connection"

}

3. In the .xsjs file, reference the .xssqlcc file in getConnection() ...

var conn = $.db.getConnection("hana_hello::anonuser");

4. Finally, update the "_SYS_XS"."SQL_CONNECTIONS" table. Set the username to someone that has access to the database you are trying to call. This should happen in the SQLCC application, but it doesn't seem to work ... this is the code that is in that application.  Run the SQL command ...

UPDATE "_SYS_XS"."SQL_CONNECTIONS" SET username = 'ANON_USER1' WHERE name = 'hana_hello::anonuser';

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

>Finally, update the "_SYS_XS"."SQL_CONNECTIONS" table.

You shouldn't really update the table directly. There is an application provided to do this.

Its available at /sap/hana/xs/sqlcc/

Former Member
0 Kudos

Hello Michael,

The post is really helpful. Thanks

former_member194780
Active Participant

Hi Thomas,

I had been using SQL CC for Anonymous calls. It was working perfectly fine on SP6.

We upgraded our system to SP8 and now the application does not work.

Kindly Advice..

-Avinash