cancel
Showing results for 
Search instead for 
Did you mean: 

How to determine logged in user?

Former Member
0 Kudos

Hi Buddies,

I would like to have my application greeting the user... What I mean is if james-j starts the application, I want to determine the username and use it in my application (e.g. Hello James, ...)

Is there a way to determine the user that actually is logged in to the application?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Following code will be of use for you


IWDClientUser user;
    String greet = "Welcome ";
	try {
		user = WDClientUser.getCurrentUser();
		 greet += user.getFirstName();
	} catch (WDUMException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}

Regards

Ayyapparaj

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi,

go through this thread for fetching user details of looged in portal user:[;

Fetching User Details from the Portal and Displaying it in Web Dynpro with Authentication in the Portal

[https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e039ce31-4156-2b10-1481-bdc3ff8cae48]

Protecting Access to the Web Dynpro Application Using UME Permissions

[http://help.sap.com/saphelp_nw04/helpdata/en/f3/a64d401be96913e10000000a1550b0/frameset.htm]

Integrating UME Permissions in the Web Dynpro Application - Steps

[http://help.sap.com/saphelp_nw04/helpdata/en/d0/13214166abc059e10000000a155106/frameset.htm]

Regards,

Khushboo

Former Member
0 Kudos

Hi Johannes,

This procedure is for currently logged in user access.

You should add security.api.jar for UMFactory

Right click on your project name--->java buildpath ? Libraries>Add Variables --> Eclips home >Extend>Plugin-->com.sap.security_2.00 --> lib --> com.sap.security.api.jar .

Create Username and Email id context attributes. And Bind it with the UI elements like textview.

Write the below code in view implementation init method.

doinit method () implementation

try {

String firstName = WDClientUser.getCurrentUser().getFirstName();

String lastName = WDClientUser.getCurrentUser().getLastName();

String name = firstName + " " + lastName;

wdContext.currentContextElement().setUser(name);

ISearchResult rst = UMFactory.getUserFactory().getUniqueIDs();

IUser iuser = null;

while (rst.hasNext()) {

iuser =

UMFactory.getUserFactory().getUser(rst.next().toString());

if ((firstName.equalsIgnoreCase(iuser.getFirstName())) & (lastName.equalsIgnoreCase(iuser.getLastName()))) {

String emailId = iuser.getEmail();

wdContext.currentContextElement().setMailID(emailId);

}

}

} catch (WDUMException e) {

e.printStackTrace();

} catch (UMException ue) {

ue.printStackTrace();

}

See this threads also

/thread/99462 [original link is broken]

/thread/198332 [original link is broken]

With Regards,

Roop Kumar.

Former Member
0 Kudos

Hi

follow this application

*Fetching User Details from the Portal and Displaying it in Web Dynpro with Authentication in the Portal*

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e039ce31-4156-2b10-1481-bdc3ff8c...

Edited by: Nikhil Tapkir on Sep 2, 2008 4:11 PM

Edited by: Nikhil Tapkir on Sep 2, 2008 4:11 PM

venkatakalyan_karanam
Active Contributor
0 Kudos

Hi

Please see the code

public void GetLogonID(){

//@@begin GetLogonID()

String LogonID;

try{

/* create an user object from the current user */

IWDClientUser wdUser=WDClientUser.getCurrentUser();

IUser user=wdUser.getSAPUser();

if(user!=null){

IUserAccount acct=user.getUserAccounts()[0];

if(acct!=null)

LogonID=acct.getLogonUid();

else

LogonID="acct null";

}else {

LogonID="user null"; }

wdComponentAPI.getMessageManager().reportSuccess(user.getFirstName()" "user.getLastName());

wdComponentAPI.getMessageManager().reportSuccess(LogonID.toUpperCase());

}catch(Exception e){

e.printStackTrace();

}

//@@end

}

Regards

Kalyan

Former Member
0 Kudos

Hi,

check this link,

https://www.sdn.sap.com/irj/sdn/wiki?path=/display/wdjava/checkallUserswhohaveloggedintoportal-webdynproappl

To Add the Jar:

Regards,

ramesh

Edited by: Ramesh Babu V on Sep 2, 2008 3:48 PM