locked
get Country of loggedin user in sharepoint online RRS feed

  • Question

  • Hi to All,

    i am using SharePoint Online, and need to get the country of logged in User ..

    how can i do this ?

    please reply.

    Sunday, August 14, 2016 6:32 PM

Answers

  • Use REST Api to pull the information like below, for the current logged in user

    http://siteurl/_api/SP.UserProfiles.PeopleManager/GetMyProperties?$select=Country

    For other user, pass the user ID in the format given below

    http://siteurl/_api/SP.UserProfiles.PeopleManager/GetUserProfilePropertyFor(accountName=@v,propertyName='Country')?@v='i:0%23.f|membership|rajesh@crazylabs.onmicrosoft.com'


    ---
    Rajesh
    rjesh.com| @rjesh
    You don't need to buy me a beer, if helpful just smile, vote, and mark it as answer.

    • Proposed as answer by Patrick_Liang Sunday, August 21, 2016 8:53 AM
    • Marked as answer by Patrick_Liang Monday, August 29, 2016 10:45 AM
    Sunday, August 14, 2016 10:47 PM

All replies

  • Pls use Geolocation.

    Here are the links

    https://social.msdn.microsoft.com/Forums/office/en-US/86653383-7416-4276-a159-9c75e1d18560/i-want-to-know-the-geo-location-of-logged-in-user-in-o365-sharepoint-site?forum=sharepointdevelopment

    http://sharepoint-community.net/forum/topics/how-to-get-the-current-logged-user-location-id-in-sharepoint


    Please remember to click Mark as Answer on the answer if it helps you

    Sunday, August 14, 2016 8:07 PM
  • i did not mean the visitors, i mean the country for the user from his user profile, 

    when we are creating any user, we put the country as part of his registration information, i need to pull that information back from his user profile.

    please reply.

    Sunday, August 14, 2016 10:13 PM
  • Use REST Api to pull the information like below, for the current logged in user

    http://siteurl/_api/SP.UserProfiles.PeopleManager/GetMyProperties?$select=Country

    For other user, pass the user ID in the format given below

    http://siteurl/_api/SP.UserProfiles.PeopleManager/GetUserProfilePropertyFor(accountName=@v,propertyName='Country')?@v='i:0%23.f|membership|rajesh@crazylabs.onmicrosoft.com'


    ---
    Rajesh
    rjesh.com| @rjesh
    You don't need to buy me a beer, if helpful just smile, vote, and mark it as answer.

    • Proposed as answer by Patrick_Liang Sunday, August 21, 2016 8:53 AM
    • Marked as answer by Patrick_Liang Monday, August 29, 2016 10:45 AM
    Sunday, August 14, 2016 10:47 PM