Logo 
Search:

Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

User Display Name

  Asked By: Blair    Date: Nov 02    Category: Sharepoint    Views: 2733

I have one user in my portal where their Preferred Name shows up as
their Account Name. So any place where there is an audit (modify by,
created by) it shows up domain\username. It does not do this for an
Area Detail web part.

Every other users credentials show up correctly. Is there a way to
correct this? I have checked this particular users profile in the
profile database and everything looks correct.

Share: 

 

4 Answers Found

 
Answer #1    Answered By: Ted Gilmore     Answered On: Nov 02

I hope someone else chimes in here. We have the same problem on occasion and must modify  the user  under Site Collection admin.

 
Answer #2    Answered By: Monte Cooley     Answered On: Nov 02

That fixed my problem.

Could this happen by accessing the portal  before a profile  import occurs?

 
Answer #3    Answered By: Guadalupe Bullock     Answered On: Nov 02

You can always go out the AD and pull the information you are looking
for.

Here is a quick web  part I pulled together one day to put a
salutation, User Name and suffix onto a SPS or WSS site.

(i.e. Welcome Gord Barker to our Portal...like that)

CSS control over all parts, configurable from the toolpage.

using System;
using System.DirectoryServices;
using System.ComponentModel;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml.Serialization;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.WebPartPages;
using Microsoft.SharePoint.WebControls;
using System.Security;
using System.Security.Principal;
using System.Security.Permissions;

namespace UserName
{
/// <summary>
/// Description for SiteNavigation.
/// </summary>
[DefaultProperty("Text"),
ToolboxData("<{0}:UserName runat=server></{0}:UserName>"),
XmlRoot(Namespace="UserName")]
public class UserName : Microsoft.SharePoint.WebPartPages.WebPart
{
#region Parameters
#region Salutation
private string _salutation = "Welcome";
[Browsable(true),
Category("UserName"),
DefaultValue("Welcome"),
WebPartStorage(Storage.Shared),
FriendlyName("Salutaion to apply"),
Description("Salutation to the Users Name")]
public string Salutation
{
get{return _salutation;}
set{_salutation = value; }
}
#endregion
#region Suffix
private string _suffix = "to our Portal";
[Browsable(true),
Category("UserName"),
DefaultValue("to our Flint Energy"),
WebPartStorage(Storage.Shared),
FriendlyName("Suffix to apply"),
Description("Suffix to the Users Name")]
public string Suffix
{
get{return _suffix;}
set{_suffix = value; }
}
#endregion
#region CSS
private string _salutationstyle = "";
[Browsable(true),
Category("UserName"),
DefaultValue(""),
WebPartStorage(Storage.Shared),
FriendlyName("CSS Style to apply to the Salutation"),
Description("Apply this CSS StyleSheet to the Salutation text")]
public string SalutationStyleName
{
get{return _salutationstyle;}
set{_salutationstyle = value; }
}
private string _suffixstyle = "";
[Browsable(true),
Category("UserName"),
DefaultValue(""),
WebPartStorage(Storage.Shared),
FriendlyName("CSS Style to apply to the Suffix"),
Description("Apply this CSS StyleSheet to the Suffix text")]
public string SuffixStyleName
{
get{return _suffixstyle;}
set{_suffixstyle = value; }
}
private string _namestyle = "";
[Browsable(true),
Category("UserName"),
DefaultValue(""),
WebPartStorage(Storage.Shared),
FriendlyName("CSS Style to apply to the Name"),
Description("Apply this CSS StyleSheet to the User Name text")]
public string UserNameStyleName
{
get{return _namestyle;}
set{_namestyle = value; }
}
private string _stylelocation = "";
[Browsable(true),
Category("UserName"),
DefaultValue(""),
WebPartStorage(Storage.Shared),
FriendlyName("CSS location"),
Description("Location of the CSS to apply")]
public string StyleLocation
{
get{return _stylelocation;}
set{_stylelocation = value; }
}
#endregion
#endregion

protected override void RenderWebPart(HtmlTextWriter output)
{
string html, SalutationCSS, SuffixCSS, NameCSS;
Impersonate.AppPoolImpersonate AppPoolUser;
string strUserName = System.Environment.UserName;

DirectoryEntry RootDSE = new DirectoryEntry("LDAP://RootDSE");
string rootpath =
RootDSE.Properties["defaultNamingContext"].Value.ToString();

DirectorySearcher ds = new DirectorySearcher("LDAP://" + rootpath);

ds.Filter = "(sAMAccountName=" + strUserName + ")";
ds.PropertiesToLoad.Add("displayName");

AppPoolUser = new Impersonate.AppPoolImpersonate();

SearchResult srchRes = ds.FindOne();
if(srchRes != null)
{

if (srchRes.Properties["displayName"] != null &&
srchRes.Properties["displayName"].Count > 0)
{
string strDisplayName =
srchRes.Properties["displayName"][0].ToString();

if(StyleLocation.Length > 0)
output.Write("<link rel=stylesheet href=\"" + StyleLocation +
"\" >");

SalutationCSS="";
if(SalutationStyleName.Length > 0 )
SalutationCSS="class='" + SalutationStyleName + "'";

SuffixCSS="";
if(SuffixStyleName.Length > 0 )
SuffixCSS="class='" + SuffixStyleName + "'";

NameCSS="";
if(UserNameStyleName.Length > 0 )
NameCSS="class='" + UserNameStyleName + "'";

html = "<span " + SalutationCSS + ">" + Salutation +
"</span><span " + NameCSS + "> " + strDisplayName + "</span><span " +
SuffixCSS + "> " + Suffix + "</span>";
output.WriteLine(html);

}
}
AppPoolUser.Revert();
}
}

}

and the Impersonate module looks like this

using System;
using System.Web.Security;
using System.Security.Principal;
using System.Runtime.InteropServices;

namespace UserName
{
/// <summary>
/// Summary description for Impersonate.
/// </summary>
public class Impersonate
{
public class AppPoolImpersonate
{
[DllImport("advapi32.dll", SetLastError=true)]
private static extern int RevertToSelf();
WindowsIdentity connectedUser;

public AppPoolImpersonate()
{
connectedUser = WindowsIdentity.GetCurrent();
RevertToSelf();
}
public void Revert()
{
connectedUser.Impersonate();
}
}
}
}

 
Answer #4    Answered By: Nathanial Mcclure     Answered On: Nov 02

This looks really interesting - but for some mad reason that I cannot
see, I'm having trouble actually using it.

I've packaged it up as a webpart and done the "10 steps to making a
webpart" as I remember them but I get the dreaded "...not registered on
this site as safe." message.

Obviously, I must be making a typo somewhere or just simply missed out
something but I just cannot see it.

Do you have a nicely zipped up vs project somewhere with this in I can
compare mine to?

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




Tagged: