SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm developing a visual webpart (TreeView). If I click on a node (folder), it gives me the credentials of the folder. Now, the values are all appearing in a label.

How can I return the users and groups not as string, but as a "SPUser-Hyperlink" like you can see in lists, when you create a coloumn and select the field "persons and groups".

share|improve this question
String UserName= “UserNameGoesHere”; 

SPUser oUser= SPWeb.EnsureUser(UserName); 

Where “UserNameGoesHere” you can change that to a varible as you loop through each string.

or from msdn

SPSite oSiteCollection = SPContext.Current.Site;
using (SPWeb oWebsite = oSiteCollection.AllWebs["Website_Name"])
    SPUser oUser = oWebsite.AllUsers["User_Name"];



You would need to iterate through all the names by having in the using a while or forloop to go through the whole list!

hope this helps :)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.