Monday, July 3, 2006 - Display Username
Click here to download a small assembly (wcdisplayusername.dll) that can be used to display the currently logged in user's name, login name or both together.
It has been strong named so you can drop it in your GAC and you will not need to raise the trust level in the web.config file. However you will need to add it as a safe control:
ltSafeControl Assembly="WCDisplayUserName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=638bf0fcc8cd630a" Namespace="WCDisplayUserName" TypeName="WCDisplayUserName.DisplayUserName" Safe="True" /gt
Simply register a tag prefix for it on the sharepoint page (this works on both WSS and SPS pages) you want to use it on like so:
lt%@ Register Tagprefix="xx" Namespace="WCDisplayUserName" Assembly="WCDisplayUserName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=638bf0fcc8cd630a"%gt
Put the control where you want it on the page like this:
ltxx:DisplayName DispOption="un" runat="server" /gt
Valid values for DispOption are:
un to display username
ln to display loginname
ul to display username (loginname)
[note]I have had to write lt and gt rather than the actual characters because my blog writing software is a bit rubbish in that it will try and render the contents regardless of how I type them in the source. I'll figure it out sooner or later though[/note]
DAN'S DISCLAIMER
I can not and will not be responsible for any adverse side-effects resulting from the use of any code, programs, assemblies or any thing else that you use or download from my website or this blog. If I say it works I mean that it works on my home PC or on any of the computers that I may have used it on at my place of work.
|