Jean Paul's Blog

There are 2 types of People in the World, One who Likes SharePoint and..

  • Microsoft MVP

  • MindCracker MVP

  • CodeProject MVP

  • eBook on SharePoint 2010

  • eBook on Design Patterns

  • eBook on Windows Azure

  • NLayers Framework @ CodePlex

  • MSDN Forums

  • .Net vs. Java

    Due to Public Demand

What is Ensure User?

Posted by JP on April 8, 2013


In this article we can explore a new command associated with Squadron > Explorer add-in.

What is Ensure User?

Ensure User is the command that invokes EnsureUser() method for the SPWeb objects specified.

Why we need to call it?

For each new user in a web site, a user record is added to the User Info table. For new SharePoint installations, when the users login to the site first time, there will be simultaneous addition of records to the above table & might result in SQL Server Throttling error.

A wise advice for the problem is to add the user explicitly to each web site before the opening SharePoint to public.

image

Squadron is a Free SharePoint Administration tool available at www.sharepointcto.com.

image

How to perform Ensure User?

Please download & Install the latest version of Squadron. After executing it in Farm Account mode you will receive the following screen.

image

Enter the URL in the top pane & click the Explorer item from left pane. In the appearing SharePoint Web Application view, select you web item.

image

Click on the Ensure User button visible in the screen. In the appearing dialog enter the user names in the format DOMAIN\User:

image

After entering the user names, click the Execute button in the bottom to continue. You will get the following message box after operation is completed.

image

This makes sure that the user is available in the UserInfo table for the particular web site. This will prevent the possible SQL Server Errors happening in SharePoint Installations with hundreds of users.

image

You can also invoke the Ensure User within the Web Application & Site Collection level. The same button will be enabled for those commands.

For Web Application item selection:

image

For Site Collection item selection:

image

On invoking the Ensure User command, all the Web items will be enumerated in the selection dialog. You can select the web items to be processed for.

image

Following is the code that performs the EnsureUser() method invoking.

foreach (string user in UsersText.Lines)
            {   
                if (string.IsNullOrEmpty(user))
                    continue;

                foreach (int i in WebList.CheckedIndices)
                {
                    SPWeb web = WebList.Items[i] as SPWeb;
                   
                    try
                    {
                        web.EnsureUser(user.Trim());

                        SquadronContext.WriteMessage("Success: " + web.ToString() + " " + user);
                    }
                    catch (Exception ex)
                    {
                        SquadronContext.WriteMessage("Failure: " + web.ToString() + " " + user + " " + ex.ToString());
                    }
                }
            }

References

http://bit.ly/10uiVpB

Summary

In this article we have explore the Ensure User command. There are more commands associated with the Explorer Add-in of Squadron – plus, they are context sensitive based on Site / Web / List / Item types.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s