Skip to Content
avatar image
Former Member

How to determine logged in user?

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?

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

6 Answers

  • Best Answer
    avatar image
    Former Member
    Sep 02, 2008 at 10:19 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 02, 2008 at 10:25 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 02, 2008 at 10:15 AM

    Hi,

    check this link,

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

    To Add the Jar:

    getting-current-login-id

    Regards,

    ramesh

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

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 02, 2008 at 10:16 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 02, 2008 at 10:23 AM

    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-bdc3ff8cae48

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

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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 02, 2008 at 10:48 AM

    Hi,

    go through this thread for fetching user details of looged in portal user:[retriving user details from user rofile in portal database;

    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

    Add comment
    10|10000 characters needed characters exceeded