Logged in user ID retrieval irrespective of UME?

Hi,
I have found below code which can retrieve currently logged in user and it's working fine.  Reading the code I assume this will only work if the user datasource is ABAP, will the below code work if we change to LDAP as user datasource?  If not, is there a generic coding which can be used to retrieve logged in userid irrespective of user datasource?  We are currently using ABAP as datasource, but we will be moving to LDAP soon, so I'm writing a WD app which needs to work in both situation.
String strUserName = null;
     try {
          IWDClientUser wdClientUser = WDClientUser.getCurrentUser();          
          IUser sapUser = wdClientUser..getSAPUser();
          if (sapUser != null) {
               IUserAccount[] acct = sapUser.getUserAccounts();
               if (acct[0] != null) {
                    strUserName = acct[0].getDisplayName();
     } catch (WDUMException e) {
          e.printStackTrace();
     } catch (UMException e) {
          e.printStackTrace();
     return(strUserName);
Thanks
Praveen

I found this WIKI and thread
retriving user details from user rofile in portal database
/people/sap.user72/blog/2005/06/05/user-management-api-in-webdynpro
Which says that below code
IUser iUser = user.getSAPUser();
getSAPUser() method, though it says SAP User it's not direct retireval from ABAP, it's from SAP Web App Server user which could be any datasource (R/3, LDAP, Portal UME). 
If you read in the blog right at the bottom in the user comments sections you will find clarification on getSAPUser and portal user.  This answers my question that I can use user.getSAPUser() method irrespective of user datasource(r/3, LDAP, UME).
If my understanding is wrong please advise.  I'm marking this thread answered.
Thanks
Praveen
Edited by: Praveen11 on Oct 16, 2009 3:14 AM

Similar Messages

  • How to retrieve the username of the logged in user

    Hi, I've been looking for a possibility retrieve some user data like the username of the currently logged in user since yesterday but could not find anything proper. I'm relatively new to APEX. Could someone perhaps point me to an easy-to-understand document? I would be glad if it would also cover the basic of authentication and authorization schemes.

    Hi, thanks for your reply. I've already changed my handle but the system said that it would take about one hour for the change to be done.
    Actually I have the following situation. I have a table that associates IDs to names. The names are the same as the user names of the users in APEX. On an APEX-Page I have a select-box that lists all available IDs. What I want to do is to automatically pre-select the ID of the currently logged in user. So I have created an authentication scheme as described in the help using following options:
    Based on a pre-configured scheme from the gallery > Show Login Page and Use Application Express Account Credentials
    And then I made the new authentication scheme the application's current scheme. Then I went to the page definition and created a new process, selecting "On Load - After Regions" as "Process Point", and entered the following source:
    declare
    nID number;
    begin
    :P2_TEMP := :APP_USER; -- this is just for debug purposes
    select b.ID into nID from MYTABLE b where b.NAME = :APP_USER;
    :P2_ID := nID;
    exception
    when others then
    null;
    end;
    But it doesn't work. Since the text field P2_TEMP stays empty I believe I am doing something wrong with APP_USER. Anybody who can help me with that?
    Edited by: user10977071 on 05.04.2009 08:57

  • Retrieving information about the logged in user in Power BI for O365

    I am trying to retrieve the email of the current logged in user so i can pass it into a query to my sql server which then adjusts the data based on who is viewing a power bi dashboard. If anyone knows a way to grab that information or even the url that
    the file has, then i can parse out its location and change my data based on that as well.

    Currently row level security is not supported in Power BI.
    Thanks,
    Sagar K 
    (Blog: http://datamazik.blogspot.in/)

  • Retrieve log on user's name in class SimpleUICommand

    Hi everyone, I would like to retrieve current log on user name in the method execute(IScreenflowData sfd) in class SimpleUICommand, found at https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/kmc/Implementing%20Flexible%20UI%20One-Step-Screenflow.article.
    Since there is no request to work with so I tried the following code
    try {
      String userName = AccessContextFactory.getInstance().getContext().getUser().getEmail();
    catch (ContextUnavailableException e)
      PortalRuntime.getLogger().severe("ContextUnavailableException");
       e.printStackTrace();
    But I got ContextUnavailableException in the log.
    How can I retrieve log on user name in this case? Is it a general method to do this in case there is no request ?
    Thanks for reply.
    Best regards.
    Wang

    Hi Wang,
    without having tested it, it seems that the framework calls <i>setTargetParameters</i> (hopefully before <i>execute(IScreenflowData sfd)</i> is called). If this is the case, you'll have the IResourceContext at hand. From this you can retrieve the user.
    Hope it helps
    Detlev

  • RTMF apis to retrieve logged in users in portal

    Hi Experts
    Can anyone tell me if there is any RTC api available that can be used in webdynpro java to fectch the list of logged in users in the portal.
    Also if the apis are not available in webdynpro java, can these be used in portal components?
    Thanks
    Siva

    Hi,
    You should read the wiki : [List of logged on users in the Portal |http://wiki.sdn.sap.com/wiki/display/Snippets/Listofloggedonusersinthe+Portal]
    Regards,
    Pierre

  • Passing customer id(logged in user)  to BAPI

    Hi,
    I am creating a sales order application where in i have to pass the user id (customer  logged in through portal) .
    I have made the MODEL RFC as ticket, and meta data as user id password where i have passed the service user and password.
    Now my problem is that there will be 'N' customer ids in Portal but we are not creating any customer ids in SAP ECC. We are planning to pass the user id of portal logged in user to ECC (which will be customer id) and get the data based on the customer id passed.
    Question is how do i pass customer id to BAPI, ? Do i have to make the MODEL JCO as user/password or ticket should be fine as i am getting information for only customer logged in Portal ?
    How and where do i write the the following piece of code ? Should it be in wdDo init() or in the execute method of Controller ?
    try{
    IUser user = WDClientUser.getLoggedInClientUser().getSAPUser();
    IUserAccount[] acct = user.getUserAccounts();
    if(acct[0] != null)
    String strUserid = acct[0].getLogonUid();
    customer=strUserid.substring(0,strUserid.indexOf("."));
    if(customer.equalsIgnoreCase(customer))
    wdContext.currentYOURRFC_InputElement().setCustomer(customer);
    }catch(Exception ex)
    ex.getMessage();
    Should the above code be in the component controller before i execute the BAPI ?
    your help is appreciated.
    Regards
    PN

    Hi Portal Newbie,
    Your tickets and userid/password works as following:
    Tickets: When u select SAP logon ticket (SLT), EP generates a ticket with the user id of the logged in user, attached to the ticket. Now when it reaches R/3 it will check for the same user id. If no such user id is exits it will throw an error. To over come this u can define a reference system where u can do the user mapping.
    UIDPD: When u select this option u have to manually enter the user id and password in JCo. So when a EP user logs in the UID and password mentioned in JCo will be passed, not the EP user id, and R/3 will look for that user and execute the BAPI. And i guess u dont want that.
    Solution:
    As far as i have understood u dont want the same number of users in EP and R/3, (might be a licensing issue) and want only a few user IDs in R/3.
    1. Select UIDPD in JCo, and in your BAPI add another field like "user_id" through which u can send the user id to R/3 and execute a query which shall return the value corresponding to that particular user. [issue: there is a limit to the JCo connections created for a user.] Also there is an api to handle JCo connection in webdynpro. There u can set the user id, password and client number. But here also the user id that you set should be present in R/3.
    2. Select SLT in JCo and configure a reference system. You have to perform user mapping for every user. Now when a user logs in the ticket will contain the user id of EP and also the one u have mapped, ie the R/3 user. Make sure the R/3 user id exists in R/3. Now the sy-unam in BAPI will contain the R/3 user id. I guess there is an option to retrieve the EP user id from the ticket, but im not sure.
    In your kind of scenario its always recommended to have same number of user ids in EP and R/3. If user names are same then there is no need to configure reference system.
    Regards,
    Piyush.
    ps: reference system is just a system that we create in EP but in UME settings we have to specify this system as the reference system.

  • Getting logged in user id in EJB

    Hi All,
         I have a session bean which will be exposed as webservice and will be consumed in webdynpro. Both by EJB and webdynpro are running on the same WAS . Is it possible to retrive the logged in portal user id in the EJB insted of webdynpro . if so can you please provide how it can be done.
    Regards,
    Raj
    Edited by: Raj A on May 27, 2008 6:02 AM

    I found this WIKI and thread
    retriving user details from user rofile in portal database
    /people/sap.user72/blog/2005/06/05/user-management-api-in-webdynpro
    Which says that below code
    IUser iUser = user.getSAPUser();
    getSAPUser() method, though it says SAP User it's not direct retireval from ABAP, it's from SAP Web App Server user which could be any datasource (R/3, LDAP, Portal UME). 
    If you read in the blog right at the bottom in the user comments sections you will find clarification on getSAPUser and portal user.  This answers my question that I can use user.getSAPUser() method irrespective of user datasource(r/3, LDAP, UME).
    If my understanding is wrong please advise.  I'm marking this thread answered.
    Thanks
    Praveen
    Edited by: Praveen11 on Oct 16, 2009 3:14 AM

  • Sharepoint 2013 delivers documents through IIS too good! Need to restrict by logged in user

    I have a Sharepoint 2013 app that lets external users (https://) pull data from SQL to create links on the page that the user can click on to get documents to pop-up in the browser so they can view/save them.  The page sends the user's ID as a parameter
    and the stored proc uses that to return only the documents that user is allowed to see.  Took forever to figure out... looks great... my employer is going to be impressed and save money... yada, yada yada!  Problem is:  If you knew the name
    of a directory on the mapped location and knew the filename (somehow), and you had a login that got you to the site, you could successfully put that address in your address bar and the document would come up!  That's a bad thing!  I need to only
    let users see documents they have access to.
    I have been playing with the app pool settings and advanced settings for the sub-site, but it still lets me pull items that the logged-in user doesn't have permissions on the server to get to.  I haven't been able to prove it, but I suspect that IIS
    is sending another login credential to the directory to retrieve the file... something like "admin" or something that can have wider access.
    Here is my setup:  I have a directory on another server that is mapped to the Sharepoint Server box.  I have a Virtual Directory that points to that mapped drive.  My Sharepoint Page is on a site of its own and is called with the URL "https://reportcenter.<company
    name>.com".  There is only one page on the site.  When the page opens it provides links to documents on the Virtual Directory.  When you click on any of them the files appear in the browser just fine.  Sharepoint is running on a
    Windows 2012 R2 Standard OS.  The test user I am using is "Client1" and they are a member of the "SP_Clients" group which is not a member of anything else in Active Directory.  In the file directory I went to the Share list and
    made sure my test user and the SP_Clients group is not in the list... if the system tried to use Client1 there is no way they should get access.
    Any thoughts on what I can do to stop Clients from getting to files they shouldn't be?

    Thank you for your question and reply.
    No, the identity is not passed as a URL property.  The way it works is that SP verifies the user and sends them to the default page after they sign-in.  Once there, the page evaluates the UserID value and that values is passed to a stored procedure
    as a parameter.  The user can't get to the page unless they are verified by SP, they can't somehow go around this. 
    Now, once the page loads they click on one of files they wish to see (a link on the page that was created from the results of the stored procedure call).  The link points to a virtual directory setup in IIS that points to a mapped drive where the files
    are located.  The security on the files is set on the directories in their actual location.  I just need SP to pass the user's ID to the file directory and check the sharing rights on the file to see if this user has rights to get it.  It seems
    like SP is passing some other credential (probably SP_Admin, or Admin or something) which has the ability to read the file and therefore pass it back to the screen.
    I can't put the documents in SharePoint... they have to be in a file directory. The reason is that we have an elaborate program that runs every month to create these files and places them in the correct directories.  Somehow changing that application
    to create the files and place them programmatically in a SharePoint directory is beyond the scope of the project.  Under the circumstances, it would be much simpler to just provide the user a list of the documents they have access to and have them click
    on a link on a page and have the document appear in their browser.  Everything actually works, but I just have this last piece where SP is not 'telling' the file directory the UserID of the logged in user and therefore all the documents are available.
    All that needs to be done, is to make sure the userID is passed to the file directory so it can be checked against the security there to see if the user can have the file or not.
    I hope that makes sense.  I look forward to hearing back from you with your thoughts on this and how this can be accomplished.
    Thanks,
    Scott

  • User cannot retrieve data in app on local PC

    A certain user cannot retrieve data in one application whilst being able to send data in that application. She can access the 'Finance' application, send data in that application and retrieve data but in another application, 'ICM', she cannot retrieve data whilst being able to send data in that application. The weird thing is that she can retrieve data on another PC in the same application (same ID). This means the problem of retrieving data only exists on that specific computer.
    As the problem only exists on that PC I did the following:
    - clear local application data (via eTools in BPC for Excel)
    - make sure the BPC client on that PC works => all show OK in BPC Client Log.txt (after diagnostics)
    But still no results so...
    Any suggestions...anyone?

    Hi,
    Can you try to clear "Local application information". Its in ETools--> Client Option.
    then login using connection Wizard.
    Hope it helps
    Raman

  • How to get the Capability of the Logged In User

    Hi All,
    I am trying to get the Capabilities of the logged in user, but iam only getting the capabilities of the "Configurator" irrespective of who has logged in.
    I am using the following code.
    <Field name='Capability'>
    <Display class='Label'/>
    <Default>
    <invoke name='getCapabilities' class='com.waveset.ui.FormUtil'>
    <ref>:display.session</ref>
    </invoke>
    </Default>
    </Field>
    Iam using Sun IDM 5.0 with Service Pack 4. Before service pack was installed i was getting the correct result. Now iam not getting the result after the service pack is installed.
    What might be the issue ?
    Can anyone guide me on this.
    Thanks in Advance.
    Regards,
    Siva

    hi danareed
    Could you post the code to do that?, I'm trying to get the capabilitites for Any given user from the WSObject getting the AdminGroups, but I'm unable to get the capabilities from this object, what I get is an array of AdminGroup objects, how I can get the capabilities from here?
    <get>
    <invoke name='getObjectIfExists'>
              <select>
                <ref>context</ref>
                <ref>given_context</ref>
                <ref>:display.session</ref>
                <invoke name='getLighthouseContext'>
                  <ref>WF_CONTEXT</ref>
                </invoke>
              </select>
              <s>User</s>
    <s>myUser</s>
    </invoke>
    <s>AdminGroups</s>
    </get>thanks
    Edgar Torres

  • Identity User( Find Current Logged in User) Windows Forms

    I have implemented dummy code for logging in to a windows Forms Application using Identity (Owin Auth). part of my code is as follows:
    private bool validateuser()
    bool isAuthorised = false;
    Login1 log = new Login1();
    if (DialogResult.OK == log.ShowDialog())
    Splasher.Show(typeof(frmSplash));
    userC = log.usernameTextBox.Text;
    PassC = log.passwordTextBox.Text;
    if (userC == "" || PassC == "")
    count++;
    //isAuthorised = false;
    if (count > 0) log.LoginStatus.Text = "Empty passwords or usernames are not allowed. please try again";
    if (count == 2) MessageBox.Show("You have one try remaining");
    if (count == 3) { MessageBox.Show("You have exosted your tries application will now close"); Application.Exit(); }
    validateuser();
    else
    var userStore = new UserStore<IdentityUser>();
    var userManager = new UserManager<IdentityUser>(userStore);
    var user = userManager.Find(userC, PassC);
    if (user != null)
    var userIdentity = userManager.CreateIdentity(user, DefaultAuthenticationTypes.ApplicationCookie);
    isAuthorised = userIdentity.IsAuthenticated;
    userIdentity.AddClaim(new Claim("FullName", user.UserName));
    userIdentity.AddClaim(new Claim("User_Id", user.Id));
    return isAuthorised;
    else
    count++;
    //Application.Exit();
    if (count > 0) log.LoginStatus.Text = "You may have entered a wrong password or username. Please try again";
    if (count == 2) MessageBox.Show("You have one try remaining");
    if (count == 3) { MessageBox.Show("You have exosted your tries, application will now close"); Application.Exit(); }
    validateuser();
    count = 0;
    return isAuthorised;
    When the code works fine and is able to authenticate from the database. In the current form, I'm able to get the current user by using user.UserName or id by using user.Id
    How do I get to retrieve the name or Id of the current logged in user from another form. Please Help
    Thanks
    My ASP

    Type in c.Type is giving an error. could I be missing any important reference?
    My ASP
    Hi,
    Looks from Aram's code, I found a blog from Leandro Boffi.
    http://leandrob.com/2012/02/claims-identity-c-4-0-dynamics/
    Some similar code like Aram's. You should install
    Windows Identity Foundation and the companion
    WIF SDK
    Best regards,
    Kristin
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Fetch From UWL to WD view :UWL Exception Logged in users context or session

    Hi,
    We have a requirement in which , we need to fetch all UWL Items and need to display these in a webdynpro view.
    We tried based on this link [Custom UWL|http://searchsap.techtarget.com/tip/0,289483,sid21_gci1240907,00.html].
    Coding What I have Tried is
           IWDClientUser user1 = WDClientUser.getLoggedInClientUser();
                IUser epUser1 =user1.getSAPUser();
                IPortalRuntimeResources runtimeResources = PortalRuntime.getRuntimeResources();
                wdComponentAPI.getMessageManager().reportSuccess("Version "+PortalRuntime.getVersion());
                IUWLService uwlService = (IUWLService) runtimeResources.getService(IUWLService.ALIAS_KEY);
                uwlService = (IUWLService) runtimeResources.getService(IUWLService.ALIAS_KEY);
                wdComponentAPI.getMessageManager().reportSuccess("6");
                UWLContext uwlContext = new UWLContext();
                uwlContext.setUser(epUser1);
                wdComponentAPI.getMessageManager().reportSuccess(" UML Context"+uwlContext.getUserId());     
                wdComponentAPI.getMessageManager().reportSuccess("9");
                IUWLSession uwlSess=uwlService.beginSession(uwlContext, 6000);
                uwlContext.setSession(uwlSess);
                wdComponentAPI.getMessageManager().reportSuccess(" UML Session"+uwlSess.getUser().getUniqueID());
                IUWLItemManager itemManager = uwlService.getItemManager(uwlContext);
                wdComponentAPI.getMessageManager().reportSuccess("Item manager"+itemManager.getItems(uwlContext,null,null));
                QueryResult result = itemManager.getItems(uwlContext,null,null);
                wdComponentAPI.getMessageManager().reportSuccess("12");
                int size = result.getTotalNumberOfItems();
                ItemCollection collection = result.getItems();
                java.util.List list = collection.list();
                Item item = null;
                Date date = null;
                String subject = null;
                for(int i = 0; i < 5; i++)
                if(!(i > (size -1)))
                item = collection.get(i);
                date = item.getDueDate();
                subject = item.getSubject();
                wdComponentAPI.getMessageManager().reportSuccess("item "+item);
                wdComponentAPI.getMessageManager().reportSuccess("date "+date);
                wdComponentAPI.getMessageManager().reportSuccess("subject "+subject);
    But I am getting the Exception
    Exp: com.sap.netweaver.bc.uwl.UWLException: Wed May 14 11:20:29 IST 2008 (Default) Logged in users context or session doesnt exist
    in the line
    QueryResult result = itemManager.getItems(uwlContext,null,null);
    But according to first mentioned link the user is getting through Portal Request Object. In webdynpro, we were not able to get Portal request object. So we  are getting the current user from UME .
    So we are getting the exception.
    Can anybody help me
    Thanks and Regards
    Smitha

    check this link
    Re: UWL breaks behind TAM

  • Storing Current Logged on User Details in Web Dynpro Java

    Hi Experts,
    My GP Process containd 2 steps:
       - Create Activity
       - Evaluate and Approve
    The user creates the Activity and the manager approves it.
    I have to make sure the User Details are avaialble for the Manager to see.
    How do i store the user details logged on.
    I need the "Name", "Date" and "Time" of the user when he creates the Activity.
    Can somebody guide me how to do it using Web Dynpro java.????
    Thanks a lot.
    Cheers
    Gaurav Raghav

    Hi Gaurav,
    Make use of background callable object which retrieves the logged in user details. If you are using WD and you need the logged in user infomation use the IWDClient . Code for getting this is there in sap help.
    Thanks,Uma.A

  • OIM11gr2 - How to get currently logged in user details using oim api

    Hi All,
    I have a requirement to retrieve currently logged in users profile in the process adapter.
    I have tried with getSelfProfile in tcUserOperation and also ContextManager.getOIMUser API's however, in both the cases i am getting xelsysadm details only.
    Also as know request details in Process task mapping doesnot work for OIM11g onwards (its returning column not found exception )
    DOes any one has idea how to achieve this.
    PS. - i am using platform to retrieve API's.
    Thanks & Regards
    Swati Pandey

    You can get the logged in user name using the below java code:
    ADFContext adfCtx = ADFContext.getCurrent();
    SecurityContext secCntx = adfCtx.getSecurityContext();
    String user = secCntx.getUserPrincipal().getName();
    HTH

  • Using credentials of a logged in user with JMX (Admin console extension)

    Hello,
    I would appreciate any info regarding creation of a connection to the DomainRuntimeService MBean server in an administration console extension in BEA Weblogic 9.2.
    The problem is that if I provide no security credentials, I'm not able to invoke any operations on the MBean server. Also the possibility of providing "default" user credentials within the extension "configuration" used to authenticate is not an option.
    The most convenient way would be to use the same mechanisms used by the rest of the administration console, but there seems to be very little information around about where to retrieve the username/password used to log in to the console.
    Thank you very much in advance, If you didn't understand my question, please ask for more information since English is not my native tongue.

    Hi,
    Check the following wiki content submitted by Michael Nicholls:
    https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/excel%252bspreadsheet%252bof%252bume%252bassignment%252bdata
    The code for getting groups for your case (current logged in user) should be like:-
    IWDClientUser clientUser = WDClientUser.getLoggedInClientUser();
    IUser user1 = clientUser.getSAPUser();
    Iterator groups = user1.getParentGroups(false);
    while (groups.hasNext()) {
    IGroup group = groupFact.getGroup(groups.next().toString());
    String groupname = group.getDisplayName();
    Add this group name to a list
    I do not have NWDS access at the moment so haven't checked it myself... you may try it out.
    Also check out the following threads on the same issue:
    Re: Get all Groups for current user
    Re: Portal User and Role info

Maybe you are looking for