How to obtain user id for userdisp.aspx page
-
03-10-2020 - |
Question
I have SP 2013 farm. When i want to see user, SP render for me link like this: http://portal/_layouts/15/userdisp.aspx?ID=1. Then i go for this link become redirect to http://portal/my/Person.aspx?accountname=userlogin. I want to obtain user ID from first link. But if i search user via SP search it always give me a link to Person.aspx. I saw a Profile in User Profile Service Application and can't find a property like ID. How can i get this id?
OTHER TIPS
Not exactly elegant but if you view your site collection access group with Id=0 you can find the user then hovering the mouse over that user the ID= for that user will display in the link preview.
- Go to: https://portal/_layouts/15/people.aspx?MembershipGroupId=0
- Find the user and hover mouse over
- Look at bottom of screen for link preview
- The ID= is found at the very end of the link preview
Hopefully someone else knows a better way and can post.
You can find the UserID from any place in SharePoint that displays the User Name, such as Modified by in a List or Library. Right-click on the User Name and select Properties from the flyout. It will give you userdisp.aspx?ID=39
for that that user.
I hope that helps.
You can get a list of the userIds via REST:
https://msdn.microsoft.com/en-us/library/office/dn531432.aspx#bk_User
A GET request on http://site_url/_api/web/siteusers
gives you a list of all siteusers. For each user there is a field "Id" : 1
(in JSON Format).
Trap: The ID differs per website collection!
So if you need IDs for a specific website collection you have to request
http://site_url/website_collection/_api/web/siteusers
If you already know the username and just want to obtain the ID you can get it by requesting http://site_url/_api/web/siteusers(@v)?@v='login name'
as explained in the MSDN Link.