cancel
Showing results for 
Search instead for 
Did you mean: 

get Portal logon user name for Webdynpro Application iView

Former Member
0 Kudos

Hi,

I created a Webdynpro application and also created an iView which is integrated in Portal. This application has one parameter, user name. I'm trying to get the logon user name from the Portal and send it to my Webdynpro applicaiton iView.

In the iView definition, I can put parameter value statically in Application Parameters. How can I dynamically get the log on user name?

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

former_member198228
Active Participant
0 Kudos

Hello Wei,

The current user can than be retrieved with

WDClientUser.getCurrentUser()

and you get an IUser object with

WDClientUser.getCurrentUser().getSAPUser()

Regards

Abdul

Former Member
0 Kudos

Hello Abdul,

Thanks a lot for your help. I think this is what I need.

But maybe the user setting in my system is not correct and I'm not familiar with the user management in Portal and Webdynpro, when I call getCurrentUser(), it didn't return the correct data.

My Portal is running on one server and my Webdynpro application is running on a different J2EE server. I logged onto Portal using a user name and password, and my webdynpro app doesn't need log on. When I call WDClientUser.getCurrentUser() in my webdynpro app, what user does it return back? I'm trying to get the Port user name.

Thanks for advice.

Wei

former_member198228
Active Participant
0 Kudos

Hello Wei,

The IUser object is the portal user. You can call the following to get more info

This interface provides read-access to the user's attributes, and offers basic support for authorization checking.

getFirstName()

Gets the user's first name.

getCellPhone()

Gets the user's default cellphone number.

hasPermission(permission)

Returns true if the user has the given permission.

Regards

Abdul

Former Member
0 Kudos

Thanks Abdul!

It's working!

Former Member
0 Kudos

Hi Abdul & everyone,

I cannot find any method called WDClientUser.getCurrentUser().getSAPUser(). Do i need to add some jar file or something? Please do advice.

When i try to print and see:: WDClientUser.getCurrentUser().getClientUserID(), it gives me some unique 2 digit number. The 2 digit number is unique for each logged in user.

For ex: In one login it returns "37" and for another user, it gives "41" etc...

Awaiting your reply.

<b>Regards,

Sai krishna.</b>

Former Member
0 Kudos

Hi all,

i got it.

I added the security api jar file and it worked.

<b>Regards,

Sai Krishna</b>

Former Member
0 Kudos

Hi All,

I've imported the security jar, but I'm getting the IUser as 'anonymous'. What does this mean?

My WAS and EP are running on different J2EE instances.

When I check the 'Authentication' checkbox while creating WD application and test the WD on WAS it correctly gives me the current user. In my case it is 'Administrator', which is the WAS user for testing WD.

But when I remove this check, and deploy this application onto EP, in EP I get the IUser object as 'null'. Ideally I should get the current EP user ID to be displyed in the iView.

Am I missing something?

Thanks in advance.

Regards,

-Vaibhav.

Former Member
0 Kudos

Hi Guys,

I've still not got the solution. Can anybody please help me in understanding why it is working for other people and not working in my case?

Thanks & Regards,

VaibhaV

Former Member
0 Kudos

Hi there,

I have quiet the same problem. When I have no authentication configured in my WebDynpro application I get null for the IUser... (Portal and J2EE engine on same machine).

When I configure my WD application to turn authentication on, I get a NEW LOGIN screen with user data from portal not working.

I want ONE login in the portal and just get the User ID of the logged in user to show him HIS data in the application. Sounds not very complicated and - in my point of view - is a standard scenario of every a little bit more sophisticated application then the SAP examples. It is very disapointing to see nothing like that in the example application and in the documentation, which is in fact for what I'm used to get in the J2EE world, very poor.

What do I have to do, to get such an easy thing just working????

Thanx,

Frank

Former Member
0 Kudos

Hi All,

Can any one tell me where can I download the jar file

for importing..

import com.sap.security.api.IUser;

import com.sap.security.api.IUserAccount;

Regards,

Shakthi

Former Member
0 Kudos

Hi, the jar file should be in

your netweaver was installation directory

You know the location of the com.sap.security.api.jar.

You can find this file on the J2EE Engine in the \bin\ext\com.sap.security.api.sda directory for the server.

C:\usr\sap\<SID>\JC00\j2ee\cluster\server0\bin\ext\

com.sap.security.api.sda\com.sap.security.api.sda.jar

Former Member
0 Kudos

Hi All,

Thank you for your support.

I've added the security jar in my classpath.

Still If i tried IUSer is returning NullPointerException.

What should I do to get the portal user?

Here is my code..

try {

IUser user = WDClientUser.getCurrentUser().getSAPUser();

messageManager.reportSuccess("Before calling ");

messageManager.reportSuccess("Client User ID " +WDClientUser.getClientUser("6"));

messageManager.reportSuccess("After calling ");

try{

firstName = user.getFirstName().toString();

}catch (NullPointerException nle){

messageManager.reportSuccess("inside catch block ");

nle.printStackTrace();

return;

}

Former Member
0 Kudos

Hi Sakthi,

It would be better if you start a new thread for this

write

messageManager.reportSuccess("inside catch block "+nle.toString);

See in which line you are getting exception

Regards

Rohit

Answers (0)