Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

JavaScript - Display Name

  Asked By: Bob    Date: Jan 24    Category: Sharepoint    Views: 3374

Anybody know how to get the display name or the user id through writing
a Javascript? I dont know whether this is do able... pls somebody
provide me a solution.



5 Answers Found

Answer #1    Answered By: Patricia Richardson     Answered On: Jan 24

I've a workaround - but don't know if it's the best thing - you can use AJAX to call a aspx page through javascript  this page return the User.Identity.Name, or you can enhance it to get the Fullname from the active directory through DirectoryServices, of course the called page should work under "Windows Authentication" to retrieve the logged on user.

Answer #2    Answered By: Laura Walker     Answered On: Jan 24

AJAX. Sounds good Zaki, but the thing is i hav no experience in
AJAX would much appreciate if u can send me the code. If not i hav to
think about something else? can't i validate in that page itself? or
is that the reason u r using AJAX to get the name? Other
alternatives, if any pls? desparately need this one.

Answer #3    Answered By: Deven Ghurye     Answered On: Jan 24

Try this, I've created 2 files,
1- html to show the username
2- Aspx file which get's the logged on username

The security over the aspx file should be windows integrated.

Answer #4    Answered By: Kalyan Pujari     Answered On: Jan 24

I assume that you have a webpart that contains the javascript. In this script, put the _LogonUser_ token. SharePoint will replace this token with the value from Request.ServerVariables("LOGON_USER").

Search the SDK for "token" for more information. Also, I have an example of something similar at http://www.sharepointdevelopers.net/SharePoint%20Articles/ReplaceTokens.aspx

Answer #5    Answered By: Damon Garner     Answered On: Jan 24

Drop this simple CEWP onto a Web Part Page...

It capitalizes on the _LogonUser_ token. However, because JavaScript
see's the "\" in a string as an escape character, I am putting it into a
hidden textbox before trying to display  it. Of course, if you don't need
to access it from a JavaScript string you can simply place the token
where you want the login id to show.

Didn't find what you were looking for? Find more on JavaScript - Display Name Or get search suggestion and latest updates.