Wednesday, June 19, 2013

SPSecurityTokenService.Issue() failed: System.NullReferenceException: Object reference not set to an instance of an object

Basically it is looking for alternate access mapping. Below steps for creating alternate access mapping

Login to Central Admin.

1.            Go to Application Management.
2.            Under Web Applications click Configure alternate access mappings.
3.            Click on Add Internal URLs link on the tool bar. If you want to configure intranet or internet url’s click on Edit Public URLs
4.            In the URL protocol, host and port text box, type or verify the full URL of your site that is using the FBA Authentication.
5.            Set Zone to Default and save.


Friday, June 14, 2013

Export/Import SharePoint List/Library Powershell

#Export SharePoint List
Export-SPWeb  "http://spdev5:8005" -path "D:\\Development\surya\ResourceLibrary.cmp" -ItemUrl Resource%20Library -IncludeVersions All

#Import SharePoint List

Import-SPWeb -Identity http://spdev5:8003 -path "D:\Development\surya\ResourceLibrary.cmp"

Thursday, June 13, 2013

Configure SharePoint 2010 Service application using Powershell

Below script will create services for office web apps

Word Viewing Service Application
Excel Service Application
PowerPoint Service Application

Save this file as .ps1 in your local server folder.
Open SharePoint 2010 Management Shell> create dir local folder path and run it

$saAppPoolName = "SharePoint Web Services"
$saAppPool = Get-SPServiceApplicationPool -Identity $saAppPoolName -EA 0
if($saAppPool -eq $null)
{
  Write-Host "Creating Service Application Pool..."
 
  $appPoolAccount = Get-SPManagedAccount -Identity $appPoolUserName -EA 0
  if($appPoolAccount -eq $null)
  {
      Write-Host "Please supply the password for the Service Account..."
      $appPoolCred = Get-Credential $appPoolUserName
      $appPoolAccount = New-SPManagedAccount -Credential $appPoolCred -EA 0
  }
 
  $appPoolAccount = Get-SPManagedAccount -Identity $appPoolUserName -EA 0
 
  if($appPoolAccount -eq $null)
  {
    Write-Host "Cannot create or find the managed account $appPoolUserName, please ensure the account exists."
    Exit -1
  }
 
  New-SPServiceApplicationPool -Name $saAppPoolName -Account $appPoolAccount -EA 0 > $null
     
}
 
Write-Host "Creating Service and Proxy..."
$appPool = Get-SPServiceApplicationPool -Identity "SharePoint Web Services"
New-SPWordViewingServiceApplication -Name "Word Viewing Service Application" -ApplicationPool $appPool | New-SPWordViewingServiceApplicationProxy -Name "Word Viewing Service Application"
New-SPPowerPointServiceApplication -Name "PowerPoint Service Application" -ApplicationPool $appPool | New-SPPowerPointServiceApplicationProxy -Name "PowerPoint Service Application" -AddToDefaultGroup
New-SPExcelServiceApplication -Name "Excel Service Application" -ApplicationPool $appPool

Please see below link for more information

System.ArgumentException: Exception of type 'System.ArgumentException' was thrown. Parameter name: encodedValue at Microsoft.SharePoint.Administration.Claims.SPClaimEncodingManager.DecodeClaimFromFormsSuffix(String encodedValue)

When you are working with SharePoint FBA controls like 

<asp:ChangePassword
 <asp:PasswordRecovery

you will get below error.

System.ArgumentException: Exception of type 'System.ArgumentException' was thrown.  Parameter name: encodedValue  
 at Microsoft.SharePoint.Administration.Claims.SPClaimEncodingManager.DecodeClaimFromFormsSuffix(String encodedValue)   
 at Microsoft.SharePoint.Administration.Claims.SPClaimProviderManager.GetProviderUserKey(String encodedSuffix)   
 at Microsoft.SharePoint.SPGlobal.CreateSPRequestAndSetIdentity(SPSite site, String name, Boolean bNotGlobalAdminCode, String strUrl, Boolean bNotAddToContext, Byte[] UserToken, String userName, Boolean bIgnoreTokenTimeout, Boolean bAsAnonymous)   
 at Microsoft.SharePoint.SPWeb.InitializeSPRequest()   
 at Microsoft.SharePoint.WebControls.SPControl.EnsureSPWebRequest(SPWeb web)   
 at Microsoft.SharePoint.WebControls.SPControl.SPWebEnsureSPControl(HttpContext context)   
 at Microsoft.SharePoint.ApplicationRuntime.BaseApplication.Application_PreRequestHandlerExecute(Object sender, EventArgs e)   
 at Microsoft.SharePoint.ApplicationRuntime.SPRequestModule.PreRequestExecuteAppHandler(Object oSender, EventArgs ea)   
 at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()   
 at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

There are many reasons to get this error.
1)      Make sure all the properties or attributes are correct for the control.
2)      Sometimes if you are working with forgot password or change password you can see the error. Cookies might create a problem as we are not logged in to change password.
3)      Add this attribute in the control MembershipProvider="giveyourmembershipname"
.CS FILE
public partial class ChangePassword : UnsecuredLayoutsPageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected override bool AllowAnonymousAccess
        {
            get
            {
                return true;
            }
        }



        protected void myPasswordChanged(object sender, EventArgs e)
        {
            if (Request.Cookies[".ASPXAUTH"] != null)
            {
                HttpCookie myCookie = new HttpCookie(".ASPXAUTH");
                myCookie.Expires = DateTime.Now.AddDays(-1d);
//myCookie.Path = ApplicationName();
                Response.Cookies.Add(myCookie);
                Response.Write("surya");
            }
        }

        //ContinueDestinationPageUrl="~/_layouts/DAIDS_RSC/SignIn.aspx"
    }

ASPX page
  <asp:ChangePassword ID="ChangePassword1" runat="server" MembershipProvider="RSCMemberProvider" OnChangedPassword="myPasswordChanged"
                 DisplayUserName="true" InstructionText="Enter your username and old password."
                 ContinueDestinationPageUrl="~/_layouts/DAIDS_RSC/SignIn.aspx"
                 CancelDestinationPageUrl="~/_layouts/DAIDS_RSC/SignIn.aspx"
                 >



Thursday, May 23, 2013

Remove providername of FBA user name in sharepoint 2010


#[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
#Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue
#add-pssnapin Microsoft.SharePoint.Powershell

<#
  Users.csv has list of all user names.

UserName
Suryap
Ravik
Johnp

#>

Copy below code and save it as .ps1 file. Open PowerShell window, run below script.
It will remove provider name from FBA user name.


$InputFile = "d:\surya\Users.csv"
$URL= "http://spdev5:8003"
$site = New-Object Microsoft.SharePoint.SPSite($URL)
$web = $site.openweb("")
$file = ipcsv $InputFile
$i = 1

#variables
      $fbaUserName= $null
      $fbaformattedlogin = $null
     
      foreach ($line in $file)
      {
            $fbaUserName = $line.UserName  #.csv file column name  

# update 'scmemberprovider' with your provider name

          $fbaformattedlogin = "i:0#.f|scmemberprovider|" + $fbaUserName   
          Set-SPUser $fbaformattedlogin -Web $URL -DisplayName $fbaUserName
          #Get-SPUser $fbaformattedlogin -Web $URL
           
           # $i++
           # if($i -eq 4)
          #{
           #       break;
          #}
      }          
$web.Dispose()
$site.Dispose()
     

SharePoint 2010 Service Pack1 Instllation Steps

here is the document..

https://docs.google.com/file/d/0B_OpLHHlwhiRZlRnbGphbDJweDQ/edit?usp=sharing


missing office web apps server components in a farm SharePoint 2010

Error: Some farm products and patches were not detected on this or other servers. If products or patches are missing locally, you must quit this program and install the required products and patches on this server before restarting this wizard. if products or patches are missing on other server, you must install required products and patches on specific server.

To fix this error follow below steps.

here you can see all servers patches and which server is throwing errors 

Central Admin > Upgrade and Migration > Check product and patch installation status

in this situation some times you cannot open Central Admin then check below 

1) Check all application pools are running. If not start the pools 
2)Check Web Services Site running
2) IIS server > SharePoint Central adminstation site > right click start

sometimes you might get error w3svc not running. in this case 

IIS manager > Select sites >you can see right side Action menu > start 

now you can open Central admin site.

let's say you have app1 app2 web1 web2 servers in your farm. If app2 have any errors..

Run below Powershell command

Get-SPProduct -Local

Now run the configuration wizard. It will fix your problem.

still if you have any issues run the above command in all servers.



Followers