How To get SharePoint logedin user email in provider hosted app

Hi
I am using Amazon cloud to host my provider hosted app. App is developed using chrome control and app is registered in SharePoint Online.
can any one explain how to get email Id of logged in user in SharePoint online from provider hosted App.
Regards
Kaps

Hi,
Please refer to the following article it has complete information how to get user details.
How to: Get user identity and properties in SharePoint 2013
Using PeopleManager, we can get the emailID.
PeopleManager peopleManager = new PeopleManager(clientContext);
PersonProperties personDetails = peopleManager.GetMyProperties();
clientContext.Load(personDetails, personsD => personsD.AccountName, personsD => personsD.Email, personsD => personsD.DisplayName);
clientContext.ExecuteQuery();
Please mark it answered, if your problem resolved.

Similar Messages

  • How to get the current user name in Provider hosted app using appOnlyAccessToken

    Hi, 
    Please help me, how to get the HostWeb UserName in Provider Hosted App
    i have Provider hosted App, and Anonymous Authentication is enabled on AppWeb, using appOnlyAccessToken
    Below code does not return current user who Log in in hostweb, it is returning
    SharePoint App (app@sharepoint)
    Web web = clientContext.Web;
    clientContext.Load(web);
    clientContext.ExecuteQuery();
    clientContext.Load(web.CurrentUser);
    clientContext.ExecuteQuery();
    clientContext.Web.CurrentUser.LoginName;
    Below code gives a blank name when Anonymous Authentication is enabled, if Anonymous Authentication is disabled
    app prompts for credentials 
    HttpContext.Current.User.Identity.Name
    Thanks
    Ram

    Hi,
    Since you are using a provider Hosted app if you want to get the current logged in name than do not use AppOnlyAccessToken else use AccessToken which is App + user Context AccessToken.
    then 
    Web web = clientContext.Web;
    clientContext.Load(web);
    clientContext.ExecuteQuery();
    clientContext.Load(web.CurrentUser);
    clientContext.ExecuteQuery();
    clientContext.Web.CurrentUser.LoginName;will return proper user Name.
    HttpContext.Current.User.Identity.Name will never return the user as this object is related to IIS server of your App Server not sharepoint.you should set this as Anonymous in case of provider hosted app.you can download the below sample which uses the AccessToken which has user name in it.https://code.msdn.microsoft.com/Working-provider-hosted-8fdf2d95
    Whenever you see a reply and if you think is helpful,Vote As Helpful! And whenever you see a reply being an answer to the question of the thread, click Mark As Answer

  • How to get the current user name of the host who is occupying a specific VM?

    I'm developing a winform app with c# code to manage Hyper-V. I need to remind someone if he/she would take a VM which has already been occupied by others.
    Is there any powershell cmd or WMI interface to get the current user of a specific VM?
    Thanks!

    Hiya,
    from cmd there are quser(Query user) and qwinsta(Query Session)
    which should give you that. Don't know how you can incoorperate that in C#, but that should give you something to work with :)
    https://technet.microsoft.com/en-us/library/cc785434.aspx
    https://technet.microsoft.com/en-us/library/cc788125.aspx

  • How to get Sharepoint OAuth clientId for Java application used in any tenant

    I'm developing a web application for Office365 using the SharePoint 2013 REST service.
    This app is hosted by my web server. The development language is Java.
    I plan that users in any tenant use my app via OAuth.
    How can I register my app to get clientId for OAuth?
    I attempted to register my app by seller dashboard, but it seemed like register applications
    to seller dashboard should be developed by .NET. And I couldn't use appregnew.aspx
    because cilentId from appregnew.aspx could use only in one tenant.
    Please let me know any better way to register my app.
    Thanks,
    Tarou

    Hi,
    SharePoint 2013 provide three types of app, SharePoint-hosted app, Provider-hosted app and Autohosted app. Which one do you used?
    Here is an article from MSDN for your reference:
    Guidelines for registering apps for SharePoint 2013
    http://msdn.microsoft.com/en-us/library/office/jj687469(v=office.15).aspx
    Best Regards
    Dennis Guo
    TechNet Community Support

  • How to get the Current User on the UI page?

    All,
    Could you please let me know how to get the Current user on the UI input page , i need to display the current user ID when some one clicks the submit button, i want o get the current user to display in the javascript alert box.
    Edited by: 951930 on Oct 24, 2012 12:21 PM

    lucky,
    my schema has already defined for
    <user mapField="USER_ID" default="%CurrentUser"/>
    and in my UI page
    <td oraLabel="user"></td><td oraField="user" id="userId" ></td>
    and my javascript
    function showUserId () {                        
    var curUser = document.getElementById('userId').value;
    alert(curUser);
    and i have called this function on my submit button, but i am not able to get Current Logged User ID value to show in the alert nor able to show the current logged user on the UI page.
    my requirement is on custom UI page i need to show Current Logged User in one corner of the page and also need to show the same user in alert when he submits the button.
    Appreciate for the help.
    Edited by: 951930 on Oct 25, 2012 8:42 AM
    Edited by: 951930 on Oct 25, 2012 9:06 AM

  • How to get the current user logon to portal?

    Hi Gurus,
    How to get the current user who logged into portal.
    I have a webdynpro requirement where in which I have to get the current user id who loggedinto portal which will be the input parameter of the BAPI(adaptive RFC model) which will return me employee number of the particular user.
    Can anyone send me the code to retrive the user id through webdynpro application..........
    Pts will be rewarded for useful inputs......
    Thanks in Advance,
    Dharani

    Hi Dharani,
    Using UMEfactory u can do that...
    1. create one input field,
    2. create one attribute called Uid
    3. assign Uid attribute to the input field
    4. type the following code in Doinit() method
                String uid = wdContext.currentContextElement().getUid();
         try {
         IUser user = UMFactory.getUserFactory().
         getUserByLogonID(uid);
         String userName = user.getDisplayName();
         } catch (UMException ex) {
          e.toString(); 
    5. after that go to Portal create one iview assign to particular user. then u get into the user details...
    thats it
    Regards,
    P.Manivannan

  • I changed my primary email and icloud is still set for my old email. I tried deleting my icloud but it aks me for the old password associated with the old email that I don't have anymore. Any other sugestions on how to get icloud to change emails on my i

    I changed my primary email and icloud is still set for my old email. I tried deleting my icloud but it aks me for the old password associated with the old email that I don't have anymore. Any other sugestions on how to get icloud to change emails on my ios?

    I figured it out! I changed my email & password at the icloud site, then when I deleted the icloud account on my iphone - it still showed my old email but when i typed in my current password it went through. I was then able to sign back in with my current email and password. That was too easy for the amount of time I have put into this!  Glad its finally fixed.

  • HT5361 I am unable to start or select the MAIL app. No incoming mail and no outgoing mail. I do not even know how to get an answer without email. Can you help?

    I am unable to start or select the MAIL app. No incoming mail and no outgoing mail. I do not even know how to get an answer without email. Can you help?

    Thank you Carolyn, How helpless you can feel without this App!
    Going into the App Store as you suggest, I see 'thee updates available", the first says, 'X RESTART', the second says, 'Garage Band, an error has occurred" (in red), and the third 'Memory Clean, UPDATE'.
    Am I correct in thinking that OSX is the problem, because it is waiting for a restart?
    Kind regards,
    Cy

  • How to get username from customer email id.

    Hi experts,
    How to get username from customer email id.I am using transaction XD02.
    I would be thankful for your kind replies .
    Regards,
    Sachin Hada

    Hi sachin,
    Re: Email id field
    Regards,
    Sravanthi

  • How to get the NT user id and passwd

    Hi,
    How to get the NT user id and passwd using form 6i

    You cannot get the password. Password are stored in an encrypted format. Almost never decrypted (as a security meassure). Authentication is performed by encrypting the supplied password and matching that against the stored encrypted password.
    Think about it.. just how dangerous it will be to have a function that can dump NT users and their passwords for you. How can you ever expect to "simply decrypt a password"?
    As for getting the user name. See the Win32 kernel API call GetCurrentUser(). Also note that there is a big difference as to the owner/user of a server process/thread versus the end-user of client application (possibly running on another PC) that is making the call to the server.
    Of course, none of this is related to SQL or PL/SQL - which is what I believe the subject matter of this forum is... Kindly suggest that in future you pay attention to posting the correct subject material to the correct forum.

  • How to get the logon user id?

    hi experts
    how to get the logon user id?
    thanks a lot.

    hi ,
    get the data for the user from db tables usr02  usr41..
    regards,
    venkat.

  • How to get window system user?

    Hi,
    How to get window system user use PL/SQL(form develope6i)?

    If you don't use Oracle database then you will have to do one of two things:
    (1) Now I'm back in the office I can check D2KWUTIL. The version I have comes with Forms6.0, so it is somewhat out of date, but it has a method called WIN_API_ENVIRONMENT.Get_Windows_Username - which works for NT/95 only, although I'm sure a later version will support more recent OS.
    (2) If that's no good then you'll have to use whatever facilities your database offers: I only know Oracle.
    I also repeat my suggestion that you try the Forms forum for additional help. This is the Database forum and so is focused on serverside Oracle PL/SQL. For your needs the Developer Suite forums are better.
    Cheers, APC

  • How to get list of users who reset password using FIM portal

    How to get list of users who reset password using FIM portal
    -Thanks Rakesh Sawant

    Hi Rakesh,
    I think you are looking for something like this:
    Using Powershell to list all users that had completed
    a password reset within the last 30 days
    If you found my post helpful, please give it a Helpful vote. If it answered your question, remember to mark it as an Answer.

  • How to get sharepoint online (office 365) data in cloud/windows azure (provider) hosted app using Javascript?

    How to get sharepoint online (office 365) data in cloud/windows azure (provider) hosted app using Javascript?
    I wish to retrieve sharepoint online data in html page (hosted in windows azure) using javascript and then need to play with AngularJS

    Hi,
    According to your description, you might want to get data from Office 365 SharePoint Online(also known as host web) and pass to the Provider Hosted App which is hosted
    in Windows Azure site.
    I would suggest you take a look at the links below about accessing data from the host web
     for a quick start:
    https://msdn.microsoft.com/en-us/library/office/fp179927(v=office.15).aspx#SP15Accessdatafromremoteapp_Codeexample
    http://dannyjessee.com/blog/index.php/2014/07/accessing-sharepoint-data-from-provider-hosted-apps-use-the-right-context/
    Aother sample solution for your reference:
    https://code.msdn.microsoft.com/SharePoint-2013-Get-the-0ec36bb6
    Best regards
    Patrick Liang
    TechNet Community Support

  • How to get SharePoint Groups using Javascript in SP2013 ?

    How to get SharePoint Groups using Javascript in SP2013 , not JSOM please

    Here is the code that worked for me:
    <script type="text/javascript">
    var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/sitegroups";
      var requestHeaders = { "accept" : "application/json;odata=verbose" };
      $.ajax({
        url : requestUri,
        contentType : "application/json;odata=verbose",
        headers : requestHeaders,
        success : onSuccess,
        error : onError
      function onSuccess(data, request){
    var s='';
     for (var i = 0; i < data.d.results.length; i++)
    s +=data.d.results[i].LoginName+'\n';
        alert(s);
     function onError(error) {
        alert("error");
    </script>

Maybe you are looking for

  • Need help with UTF-8 and DBCS

    I must not understand something fundamental to UTF-8, because no matter what I try, I can't get any conversion from English to Japanese or Simple Chinese or any other language. I've tried the Java tutorials, but the output I get is either blanks (in

  • Change picture size when sending picture from I-phone 5 to HP Officejet Pro 8900

    I just installed my new HP Officejet Pro 8900.  So far every thing is working great except when I sent a picture from my I-phone 5, the picture printed the full size of the 8 1/2 x 11 page.  Not only do I NOT want a picture that big but I do not want

  • Problem in infotype 0591?

    can any one done uploading data into the table control of infotype 0591? To update nominations of employes n to SAP kindly send the with code? solution rewarded.

  • Internet seems slow on macbook

    When i open safari it's slow to load up my homepage. Is this normal? Also internet browsing seems slow. I have a 20 meg connection.

  • Edit Controlling Document

    Experts, I need to make changes to a controlling document - I see the document i need to make changes in KSB1. When i double click on it, it actually shows me a material document and the movement type is 261. So what does movement type 261 mean ? and