Sunday, October 21, 2012

TIP: Remove domain from username in SharePoint 2010

Introduction


Sometimes, in SharePoint 2010, the user will see his or her name displayed as [domain name]\username, rather than the [Full Name] saved in Active Directory. Such as:




This can become problematic when configuring views to conserve limited width, as the addition of the domain in the username display may add considerably to the column width needed:



One way to address this is to configure user profile synchronization, and this is the best way as it automates resolution of this issue.  See the References for links to helpful articles on how to implement this approach.  However, this approach may not always be desirable or even feasible in some environments.  A much simpler spot approach is to use PowerShell.

Using PowerShell commandlets, you can resolve this for one user or a bunch of users at one time.  Let's get started.

Procedure

1) Open the SharePoint 2010 Management Shell as Administrator.

2) Enter the command in the format:

Set-SPUser -Identity '[domain name]\[username]' -DisplayName '[full name]' -Web [url]


3) After the command completes, a new command prompt is display (no messages).

4) To verify whether the command worked, just refresh your page:


and




5) To update the display name for all users, you need to first get the SPUser object associated with your website, and then port the results into the Set-SPUser commandlet, like so:

Get-SPUser –Web [url] | Set-SPUser –SyncFromAD



6) Running this command will generate a number of errors appearing in the command shell.  These result from the command attempting to synchronize ALL accounts, including such accounts as System, Local Service, etc, which obviously won't work. 



Ignore these errors: it worked on the others.

Summary

In this Tip, you were shown how to easily and quickly resolve a user identity appearing in the form "[domain name]\username" rather than "[Full Name]".  You were also shown how to do this for all users of a website.

References


TIP: Set Unique Item Permissions for a SharePoint 2010 List

Introduction

SharePoint 2010 allows you to set permissions not only for a list, but also for individual rows within that list.  This can be useful, for example, when building mashups and dashboards and needing to appropriately secure the source list data feeding into the mashup or dashboard so that users see only that data in the mashup they are supposed to see.  These unique permissions follow this row where ever it may appear.  For example, if you develop a custom page and use the Dataview web part to present data from a list having unique row permissions, users connecting to this page will only see those list rows displayed in the dataview that they are supposed to see.  Let's get started.

Procedure

1) Go to the target list.

2) Go to the list item for which you want to set unique row permissions.

3) Open the list item's action menu


4) Select Manage Permissions from this menu.  This takes you to the Permissions page for that row.

5) Look for the Stop Inheriting Permissions button in the ribbon.


6) Click this button.  A prompt will appear.


7) Click Yes.  The prompt closes and you are returned to the Permissions page.  Note that now you can select users and security groups and your function buttons in the ribbon have changed.  You can now change the row permissions uniquely from the parent list.



Summary

In this Tip, you were shown how to set unique permissions for a row - permissions different from the parent list.  Setting unique row permissions can be useful in those cases where you need to ensure that users see only that data they are suppose to see. These unique permissions follow the row item where ever it may appear, even when you custom develop pages and webparts to display list data.

Notes

  • If you add users and groups to a row item permissions that were not originally included in the parent list permissions, these will be added to the parent list.

References