Search code examples
sapb1service-layer

B1ServiceLayer - get user behind SSO login


we are working in a CloudControlCenter environment. Now have to login with the SAP Business One SSO (Single Sign On) over Active Directory.

So for example we do following requests:

POST https://hana:50000/b1s/v1/Login

{
"UserName": "rz-nag\\02939106",
"Password": "Start123",
"CompanyDB": "C204651_01_DEMO_SYSONE" 
}

Now we are successfully logged in.

How can we get the SAP internal user for the ad-account "rz-nag\02939106"?

GET https://hana:50000/b1s/v1/Users has no field for this reference...

I checked service layer documentation


Solution

  • Based on the information in the Service Layer Metadata, it appears that you should be able to retrieve the WindowsUser property from the UserActionRecord Collection.

    Although I don't have an SSO or Cloud system available for testing, I found that using the GET /b1s/v1/Users(1) endpoint allows me to obtain the UserActions along with the WindowsUser information.

    It's unfortunate that accessing this field directly from the object itself is not straightforward, but this limitation is also present in the DI API.

    If this solution doesn't meet your requirements, you can consider using a view to expose the desired field.