Tuesday, July 12, 2011

How to Hide User Names in Created by, Modified by Fields in SharePoint

Requirement:  Had to provide complete anonymous entries in SharePoint task list by masking user names (as in SharePoint Surveys).

Here is the Trick: There is a Property for SharePoint List, called "ShowUser". we can set that to "False" using PowerShell or C# object model.

PowerShell script to Hide User Names in SharePoint:
$SPweb=Get-SPWeb "http://sharepoint"
$SPlist=$SPweb.Lists["Tasks"]

$SPlist.ShowUser=$false
$SPlist.Update()
sharepoint hide user name


and here is the effect in action:

sharepoint mask user names

For SharePoint 2007 Hide User Name:
For MOSS 2007, You can do the same using C# code (PowerShell also possible!)

namespace HideUserInfo
{
    class HideUserInfo
    {
        static void Main(string[] args)
        {

            using (SPSite oSPSite = new SPSite("http://SharePoint.com"))  //Site collection URL
            {
                using (SPWeb oSPWeb = oSPSite.OpenWeb("News"))  //Subsite URL
                {
                    SPList oSPList = oSPWeb.Lists["Pages"];   //List/Library Name
                    oSPList.ShowUser = false;
                    oSPList.Update();
                }
            }
        }
    }
}



You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Check out these SharePoint products:

5 comments :

  1. Hi salaudeen,

    what do we deploy it as ? Is it as a feature or something else please let me know the options if i use c# to achieve this.

    ReplyDelete
    Replies
    1. It can be in feature receiver code, list/site provisioning code, etc.

      Delete
  2. Hi Salaudeen,

    How to get a list of all external users based on "modified by" column in SharePOint Site collections?

    ReplyDelete
  3. Hi,

    have you ever tried to use a filter on the column "modified by" when you see the list? I see the list entries masked but the filter is showing me the clear user names and I can filter down the entries!?

    Cheers
    JK

    ReplyDelete
  4. I added this to discussion board which looked like it worked fine. However I wasn't able to reply for the topic as it kept on saying "Invalid data has been used to update the list item. The field you are trying to update many be read only"

    ReplyDelete

Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...