deletecollection bug in SPUserUtil 2.5 - fix described

Someone noted this problem to me, and I just confirmed it to be a bug with the deletecollection operation in SPUserUtil.

The problem is that regardless of what you have specified in your usermap file when you run the deletecollection operation, it removes more users than you specified.

This is fixed in the current build, but in the released version in the utility suite, you'll need to make this slight correction:

In the file WebUserUtil.cs, in the method DeleteSiteUsers(), make the following change as noted in "Bug fix 07/24/2006"

 

/// <summary>

/// Removes any users found in the usermap from the specified site.

/// </summary>

/// <param name="site"></param>

/// <returns></returns>

public int DeleteSiteUsers(SPSite site)

{

   int iUser = 0;

   bool bContinue = false;

   Logging.Information("Deleting users from Site Collection");

   try

   {

      iUser = site.RootWeb.SiteUsers.Count;

      while (--iUser >= 0)

      {

         // BEGIN Bug fix 07/24/2006

         // Reset continue boolean.

         bContinue = false;

         // END Bug fix 07/24/2006

         SPUser user = site.RootWeb.SiteUsers[iUser]; // Can't use the itterator (foreach) while I'm deleting users.

         if(m_Options.strUserMapFileName != null)

         {

            UserMapItem uMap = getUserMap(user.LoginName); // See if this is a migrating user.

            if(uMap != null)

               bContinue=true;

         }

         ...

         ...

         ...

 - Keith