Wednesday, February 27, 2013

System.NotImplementedException: The method or operation is not implemented. at Microsoft.SharePoint.Administration.Claims.SPClaimsAuthMembershipProvider.GetUser(String name, Boolean userIsOnline) + SharePoint 2010 FBA


I am getting error because of below line

//MembershipUser currentuser = obj.GetUser(username, false);


Provide your authentication provider name as shown below


                    MembershipUser currentUser = Membership.Providers["RSCMemberProvider"].GetUser(username, false);
           
                    Guid newUserId = (Guid)currentUser.ProviderUserKey;

                    //string updateUserSql = "UPDATE aspnet_Users SET " + field + " = '" + value + "' WHERE UserId= '" + key + "'";
                    string FirstName = ((TextBox)(RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("txtFirstName"))).Text.Trim();
                    string LastName = ((TextBox)(RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("txtLastName"))).Text.Trim();

                   string updateUserSql = "UPDATE aspnet_Users SET FirstName='" + FirstName +"', lastname='" + LastName + "' WHERE UserId='" + newUserId + "'";

                   Response.Write(updateUserSql);

                   using (SqlConnection dbConnection = new SqlConnection(connectionString))
                    {
                        dbConnection.Open();
                        SqlCommand comd = new SqlCommand(updateUserSql, dbConnection);
                        comd.ExecuteNonQuery();
                        dbConnection.Close();
                    }

Thursday, January 31, 2013

Replace windows accounts with FBA accounts + SharePoint 2010

This summary is not available. Please click here to view the post.

Remove users from SharePoint 2010 Site with Powershell

This summary is not available. Please click here to view the post.

Remove SharePoint 2010 local users using PowerShell


Below script removes local users from SharePoint site. This one expects parameter Id you can see user id in the url when you click on any user account in the SharePoint site. Here I have prepared list of users in the csv file and looping through the users.
Sample .CSV file

UserName,ID
Test1user  ,256
Test2user ,243
Test3user  ,239


param([string]$URL = "siteurl", [string]$InputFile=$(Read-Host -prompt "Path to CSV File containing users and groups:"))

#add-pssnapin Microsoft.SharePoint.Powershell

$site = New-Object Microsoft.SharePoint.SPSite($URL)
$web = $site.openweb("")

$file = ipcsv $InputFile

#logging
$timestamp = get-date -format "yyyyMMdd_hhmmtt"
$filenameStart = "MigrationLogRemoveLocalUsers"
$logfile = ("{0}{1}.csv" -f $filenamestart, $timestamp)

$header = "Message,Error"
$header | out-file -FilePath $logfile


#variables
      $winusername = $null
      $winlogin = $null
      $fbaUserName= $null
      $fbaformattedlogin = $null
      $id= $null
    $groupname = $null
      $i=1
     
      Write-Host "Started"
foreach ($line in $file)
{


#get excel sheet cell values 
    $winusername = $line.UserName
    $id= $line.ID
     
      Write-Host "Winuser:" $winusername $line.ID
try  {
            $msg = ("{0},{1}" -f "$i  User:  $winusername", "")
            $msg | out-file -FilePath $logfile  -append
           
            $list=$web.Lists["User Information List"]
            $listItem = $list.GetItemById($id)

            write-Host("User Removed " + $listItem["Account"])
           
            remove-spuser $listItem["ID"] -web $web  -confirm:$false
            $msg = ("{0},{1}" -f "$winusername - Removed from site successfully", "")
            $msg | out-file -FilePath $logfile  -append
           
           
      }
Catch
      {
            # $_ | Out-File d:\surya\errors.txt -Append
          $msg = ( "{0},{1}" -f "Error occurred while removing user:", $_)
            $msg | out-file -FilePath $logfile  -append
      }
     
      $i++
     
           
}
$web.Dispose()
$site.Dispose()


Read users from Sharepoint 2010 site or list unique permissions

This summary is not available. Please click here to view the post.

Followers