views:

85

answers:

3

Hi all,

How does Sharepoint retrieve the user's actual name as displayed in the top right corner? e.g Welcome John Smith

I need to call this name as a variable or parameter on custom code in the XSL editor but I can't figure out how I can retrieve it, is it a global variable?

A: 

I believe it's coming in through NTLM Authentication/Active Directory. I ususally get login name DOMAIN/User in the HttpContext.Current.User.Identity.Name field, and then match against Active Directory and bring back the actual name of the user.

sassinak
A: 

SPContext.Current.Web.CurrentUser.LoginName will give you the value for the login name of the current user, as displayed in the top right of a standard portal.

If you want to use this with XSLT, you need to find a way of assigning this to an XSL parameter value at run-time.

Ian
+1  A: 

You can get a user's account name using the server variable LOGON_USER. However, this doesn't return a user's Display name.

I was able to get something working which a combination of web parts to display their name:

  1. Add a UserContextFilterWebPart (you may need to enable this web part in the web part gallery).
  2. Add a DataView webpart which queries the GetUserInfo method (part of the UserGroup.asmx web service).
    • a. Click "Connect to a web service..." in the Data Source Library pane under XML Web Services
    • b. Enter the Service description location (the URL to the UserGroup web service). Ex: http://server/sites/SiteCollection/SubSite/_vti_bin/UserGroup.asmx?WSDL
    • c. Click Connect (or reconnect)
    • d. Choose GetUserInfo for the Operation dropdown (the other dropdowns should be ok)
    • e. Modify the userLoginName parameter and check the box to allow the value to be set via web part connection. I also added a default value to test (ex: domain\login).
    • f. Click OK.
    • g. Click on the data source and click Show Data
    • h. Choose the columns you need and then drag them onto the page
  3. Connect them together using web part connections (UserContext provided to the DataView).
Kit Menke
Hi! It seems that this is the answer I need. However, could you elaborate on #2 please?
Eton B.
Sure thing! I added more detailed steps for #2.
Kit Menke
Thanks, sure seems like this will fix my problem. However, upon adding the UserContextFilter web part I started getting a "403 Forbidden" error on that page, even with admin user. I'm not sure what's causing that...
Eton B.
I got the display name using a CAML variable "UserID"
Eton B.