cancel
Showing results for 
Search instead for 
Did you mean: 

Discover AD user domain through security.api

Former Member
0 Kudos

Hi SAP Experts!

I'd like some help.

We are using the default "dataSourceConfiguration_ads_readonly_db.xml" configuration to access our Active Directory server.

Is it possible to find user domain through com.sap.security.api?

DOMAIN/user

Thanks in advance.

Regards,

Thales Pires

Accepted Solutions (0)

Answers (2)

Answers (2)

lambert-giese
Active Participant
0 Kudos

Hi Thales,

I don't have an environment to test this, but looking at the following excerpt of dataSourceConfiguration_ads_readonly_db.xml:

<principal type="account">

                <nameSpace name="com.sap.security.core.usermanagement">

                    <attribute name="j_user"/>

                    <attribute name="logonalias"/>

                    <attribute name="j_password"/>

                    <attribute name="userid"/>

                </nameSpace>

                <nameSpace name="com.sap.security.core.authentication">

                    <attribute name="principal"/>

                    <attribute name="realm"/>

                    <attribute name="domain"/>

                </nameSpace>

            </principal>

I assume that the following code will do what you want:

    return UMFactory
          .getInstance()
          .getUserFactory()
          .getUserByLogonID("Administrator") //replace this with the logon ID you're interested in
          .getUserAccounts()[0]
          .getAttribute("com.sap.security.core.authentication", "domain")[0];

For production purposes, you'll want to add some exception and NULL handling to the above code, of course. Let me know if it works.

BR, Lambert

Former Member
0 Kudos

Thanks for your reply Lambert, but it didn't work.

I solve this by mapping the attribute domain to AD attribute userPrincipalName.

Thus, I could parse it to get user domain name.

Regards,

Thales Pires

Former Member
0 Kudos

This question isn't answered yet.

I've clicked on "Assumed Answered" by a mistake.

I appreciate any help.