Monday, December 30, 2013

Create FBA custom Login page in SharePoint 2013

Changes in the Authentication providers:

_layouts/15/SP.FBA/LoginClaims.aspx






After you configure FBA : post


Create a Application page put the HTML tags as below

<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Import Namespace="Microsoft.SharePoint.ApplicationPages" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="LoginClaims.aspx.cs" Inherits="FBA.LoginClaims" MasterPageFile="~/_layouts/15/errorv15.master" %>
<%@ Assembly Name="Microsoft.SharePoint.IdentityModel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

<asp:Content ID="PageHead" ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server">

</asp:Content>

<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
   


<asp:Label ID="Name" runat="server" Text="UserName:"/>

<br/>

<asp:TextBox ID="txtUserName" runat="server" Height="22px"/>

<br />

<asp:Label ID="lblPwd" runat="server" Text="Password:"/>

<br/>

<asp:TextBox ID="txtPwd" runat="server" TextMode="Password" 

                                        Height="22px"/>

<br />


<asp:Button ID="btnLogIn" runat="server" Text="Sign In" 

                          onclick="btnLogIn_Click"/>

                    

<br /><br />

<asp:Label ID="lblMsg" runat="server" Text=""/>


</asp:Content>

<asp:Content ID="PageTitle" ContentPlaceHolderID="PlaceHolderPageTitle" runat="server">
Application Page
</asp:Content>

<asp:Content ID="PageTitleInTitleArea" ContentPlaceHolderID="PlaceHolderPageTitleInTitleArea" runat="server" >
Vendor Login site..
</asp:Content>




Server side code:

using System;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using System;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.IdentityModel;
using Microsoft.SharePoint.IdentityModel.Pages;
namespace FBA
{
    public partial class LoginClaims : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }
        protected void btnLogIn_Click(object sender, EventArgs e)
        {
            if ((txtUserName.Text.Length > 0 && txtPwd.Text.Length > 0))
            {
                bool authenticated = SPClaimsUtility.AuthenticateFormsUser(Context.Request.UrlReferrer, txtUserName.Text, txtPwd.Text);
                if (!authenticated)
                {
                    lblMsg.Text = "Invalid Username or Password";
                }
                else
                {
                    Response.Redirect(Context.Request.QueryString["ReturnUrl"].ToString());
                }
            }
            else
            {
                lblMsg.Text = "Username or Password can't be empty";
            }
        }

    }

 
}

Friday, October 18, 2013

Sharepoint 2010 user profile configuration step by step

Steps is as below

1) Create a new MySite sitecollection
2) Create a new user profile service in manage services.(If already there than delete this and create again)
3) Check the below things
1) Account should be farm account and local admin account.
2) Go to Application server click Run > Secpol.msc > Local policy > User rights Assignment > Allow log on locally Add the user.
        3) Go to DC > Administrative tools > Active directory users and computers > Select domian > Right click select Delegate control > follow the below images.









4) Go to run type service.msc Check Forefront identity manager services and Forefront identity manager synchronization services should run with 
domain account try to use the same account as above with service Service type Automatic. Do not  start it now. This will be automatic start once you start the machine.
5) Go to SharePoint central admin > Application management > manage services on server > start user profile services > Start user profile synchronization services.
6) Restart the machine. Once done check userprofile service , both forefront service in services .msc and also check the user profile synchronization services in SharePoint CA.



Thursday, October 10, 2013

SP Powershell command for Backup and Restore

site collection backup:
backup-spsite -identity http://gss-w7g-0793 -path \\GSS-W7G-0793\share\rootsite.bak

restore:
restore-spsite -identity http://gss-w7g-0793 -path \\GSS-W7G-0793\share\rootsite.bak



site backup
export-spweb -identity "http://gss-w7g-0793/Training Blank Site" -path \\GSS-W7G-0793\share\TrainingBlank.cmp -IncludeUserSecurity

restore
import-spweb -identity "http://gss-w7g-0793/Training Blank Site" -path \\GSS-W7G-0793\share\TrainingBlank.cmp  -IncludeUserSecurity


document library backup
export-spweb -identity http://gss-w7g-0793 -path \\GSS-W7G-0793\share\DocumentLib.cmp -itemurl /DC

document library restore
Import-SPWeb -Identity http://gss-w7g-0793 –Path \\GSS-W7G-0793\share\DocumentLib.cmp –UpdateVersions -Overwrite


list backup
Export-SPWeb -Identity http://gss-w7g-0793 -Path \\GSS-W7G-0793\share\listBackup.cmp -ItemUrl "/Lists/Calendar"

restore
Import-SPWeb http://site –Path export.cmp –UpdateVersions -Overwrite


document library backup
Export-SPWeb -Identity http://gss-w7g-0793 -Path C:\SP2010_Backups\testlibbkp2s.cmp -ItemUrl test -Force






Tuesday, October 1, 2013

SPServiceApplicationPool

Get-SPServiceApplicationPool 
# This will show all service application pool 
Remove-SPServiceApplicationPool TestServiceWebApplicationPool
# This will remove service application pool 

Thursday, September 26, 2013

AZURE ACS for SharePoint powershell command

$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2("C:\Certs\AzureACS.cer")
$map1 = New-SPClaimTypeMapping -IncomingClaimType "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress" -IncomingClaimTypeDisplayName "emailaddress" –SameAsIncoming
$realm=”http://india.internal.com/”
$ap=New-SPTrustedIdentityTokenIssuer -Name "Azure ACS_indigo" -Description "For india.internal.com" –Realm $realm -ClaimsMappings $map1 -ImportTrustCertificate $cert -SignInUrl "https://thisisatest-sb.accesscontrol.windows.net/v2/wsfederation?wa=wsignin1.0&wtrealm=http://india.internal.com/" -IdentifierClaim $map1.InputClaimType
New-SPTrustedRootAuthority -Name "ACS_sp2013_indigo" -Certificate $cert


https://thisisatest-sb.accesscontrol.windows.net/v2/wsfederation?wa=wsignin1.0&wtrealm=http://globalapp.internal.com/

$ap=Get-SPTrustedIdentityTokenIssuer

http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress

Delete services using Powershell

$spapp = Get-SPServiceApplication -Name "Search Service Application 1"
Remove-SPServiceApplication $spapp -RemoveData


Get all the spServiceApplicationProxy

Get-spServiceApplicationProxy

Get-spServiceApplicationProxy 67f73fe6-723a-4350-842a-1fb19a2e52cb | remove-spServiceApplicationProxy

Wednesday, July 3, 2013

SharePoint 2010 Login as another user in SharePoint 2013

Due to Security issue and cache load, In SharePoint 2013 this has been hidden.

You can try to login with below url to get the windows prompt for login with another user.

http://<site url>/_layouts/closeConnection.aspx?loginasanotheruser=true

Sunday, June 2, 2013

Step by step working with SharePoint BCS


To do.
1) Create a table in your SQL server database. Script is below.

CREATE TABLE [dbo].[TblBCS](
[ID] [nchar](10) NULL,[Name] [varchar](50) NULL,[LastName] [varchar](50) NULL)
ON [PRIMARY])

2) Go to CA -> System settings -->Manage services on server 


   Check the "Secure Store Service" is working fine.

3) Create a user account at domain leve, I have created "kumarsji"
4) Go to CA > Application management   >  Manage service applications
5) Go to "secure store service"
6) click on the new button on the ribbon menu.

 
7) Enter the details as below, Check also Contact E-mail .

8) Click on next.

9) Do not change anything click on next.

10) Select Site collection Admin in the first box and put users to other box as below.

11) After clicking on ok button , We have to set credential as below.


12) Will set the credential as below.


13) Go to sharepoint designer open site go to external content type.As below.



Wednesday, May 29, 2013

Creating Content DB with New Site Collection



Better way to approach creating the new site collection in the specific content database is to use New-SPContentDatabase and New-SPSite PowerShell commands.

    Step 1- Add New Content DB to the Web Application

New-SPContentDatabase -Name WSS_Content_Accounts -WebApplication http://sp2010

    Step 2- Create New Site Collection with Top Level Site Based on Team Site Template in the New Content DB

New-SPSite http://sp2010/sites/accounts -OwnerAlias “Training\Administrator” -ContentDatabase WSS_Content_Accounts -Name “Account Sites” -Description “Account Sites Container” -Template “STS#0?

Monday, May 27, 2013

Custom field type with visual studio 2010


Steps to create Custom field type with visual studio 2010

1) Create new project select "Empty SharePoint project"

2) Give project name "CustomFieldType"

3) Select deploy solution as a farm solution.

4) Select project and click on add "SharePoint mapped folder" go to template > xml




5) Select XML folder right click add > new item


6) Go to Data tab and select XML file. Give file name" fldtypes_CustomFieldTraining.xml " ,Be sure the xml file name should has to start with fldtypes only. Otherwise this will not work.


7) open the fldtypes_CustomFieldTraining.xml file and enter the below node.

<!--
This file ensures that your SPField class is displayed in the list of available field types -->
<
FieldTypes>
<FieldType>  
<Field Name="TypeName">TrainingCode</Field> 
<Field Name="ParentType">Text</Field>  
<Field Name="TypeDisplayName">Training Code</Field>  
<Field Name="TypeShortDescription">Training Code</Field>  
<Field Name="UserCreatable">TRUE</Field>  
<Field Name="FieldTypeClass">CustomFieldType.Training_CustomFieldType, $SharePoint.Project.AssemblyFullName$</Field>
</FieldType>
</FieldTypes>

8) Enter a class file and give the name : Training_CustomFieldType.cs
Please check the name correctly because this is used in xml file as FieldTypeClass.


9) put the below lines in the CS file.

using System;
using System.Collections.Generic;
using System.Linq;using System.Text;
using Microsoft.SharePoint;
namespace CustomFieldType
{

/// <summary>/// When a user creates a new column in a List or Content Type, they see a list of /// Field Types, such as "Single Line of Text" and "Date and Time". By creating your/// own Field Type, you can extend this list. You can also include your own logic in /// the new Field Type, such as custom code to set the default value or validate user/// input. This code example shows how to create a custom Field Type/// </summary>/// <remarks>/// To create a custom field type, create an empty SharePoint project and then add a /// new class. The new class should inherit from a SPField class. In this case, the /// field stores strings, so we inherit from SPFieldText. You must also create a /// fldtypes*.xml file and deploy it to TEMPLATES\XML in the 14 hive. class Training_CustomFieldType:SPFieldText{#region Constructors
//You must create both these constructors, passing the parameters to the base classpublic Training_CustomFieldType(SPFieldCollection fields, string fName):
base(fields, fName){
}

public Training_CustomFieldType(SPFieldCollection fields, string tName, string dName):
base(fields, tName, dName){
}
#endregion//Override this property to formulate a default value. public override string DefaultValue{

get{return "CP0001";}
}

//Override this method to validate string data.public override string GetValidatedString(object value){

//Check that it starts with CP for "Training Code"if (!value.ToString().StartsWith("MS")){

//When you throw an SPFieldValidationException users see red text in the UIthrow new SPFieldValidationException("Training code must start with 'MS'");}

//Check that it's 6 characters longif (value.ToString().Length != 6){

throw new SPFieldValidationException("Training code must be 6 characters long");}

//Always convert to uppercase before writing to Content DB.return value.ToString().ToUpper();}
}
}


10) Deploy the solution and check the custom field while creating column.




http://msdn.microsoft.com/en-us/library/vstudio/ee361616.aspx

Wednesday, May 1, 2013

Tuesday, April 23, 2013

changing the sharepoint 2010 site logo doesn't reflact for webpart pages

This has been seen that changing the sharepoint 2010 site logo doesn't reflact for webpart pages.

in that case we modify the master page as below

<SharePoint:SPLinkButton runat="server" NavigateUrl="~site/" id="onetidProjectPropertyTitleGraphic">
           <SharePoint:SiteLogoImage name="onetidHeadbnnr0" id="onetidHeadbnnr2" LogoImageUrl="/_layouts/images/siteIcon.png" runat="server"/>
          
          </SharePoint:SPLinkButton>


changed one with below code in master page

<SharePoint:SPLinkButton runat="server" NavigateUrl="~site/" id="onetidProjectPropertyTitleGraphic">
           <SharePoint:SiteLogoImage name="onetidHeadbnnr1" id="onetidHeadbnnr2" LogoImageUrl="/_layouts/images/siteIcon.png" runat="server"/>
          
          </SharePoint:SPLinkButton>

Wednesday, April 17, 2013

Remote BLOB Storage (RBS) in a Microsoft SharePoint Foundation 2010 environment

By default, these BLOBs, also named unstructured data, are stored inline in the SharePoint content database together with the metadata, or structured data. Because BLOBs can be very large, it can be helpful to move BLOB data out of the SQL Server database

RBS can provide performance gains. However, if users will frequently revise the content, using RBS will decrease performance. This is because extensive versioning will cause significant growth in both the metadata in the content database and the size of the BLOB store

RBS was designed to move the storage of BLOBs from databases on database servers to directories on commodity storage solutions. Therefore, under the specific environments that RBS was intended to be used in, you can experience performance or cost benefits. By using lower-priced storage instead of more expensive storage on a databases server, you can save on costs. RBS saves storage resources when there are fewer large BLOBs. When there are many smaller files, there is no benefit.

Most optimal use of RBS

Because RBS is a solution created for a specific set of conditions, there is an optimal use of RBS in which the benefits outweigh the costs. The optimal environment for using RBS is an environment where the following is true:
  • You want to store fewer large BLOBs (256 KB or larger) for read-intensive or read-only access.
  • The resources on the computer that is running SQL Server might become a performance bottleneck.
  • The expense of high-cost drive space is greater than the expense of increased IT operations complexity that might be introduced by using RBS.
  • RBS is typically recommended in the case where the content databases are 4 gigabytes (GB) or larger

Least optimal use of RBS

RBS is not a good solution for all environments. The costs will outweigh the benefits most of the time. The least optimal environment for using RBS would be an environment where the following is true:
  • You want to store many small BLOBs (256 KB or less) for write-intensive access.
  • The resources on the computer that is running SQL Server are not a performance bottleneck.
  • The expense of increased IT operations complexity that might be introduced by using RBS is greater than high-cost drive space.

Monday, April 8, 2013

Some Important

  • Keep in mind that although site pages are loaded from a database, web parts and their user interfaces are not. Only the configuration of the web part is stored in the database 

  • Site pages that are loaded from the file system are known as ghosted pages, and when these pages have been customized they are known as unghosted pages. 

  • SharePoint 2003 brought us ghosting/unghosting; SharePoint 2007 scrapped these terms in favor of the more descriptive uncustomized/customized. Now with SharePoint 2010, the terms attached and detached are used to prevent any ambiguity

  • Site pages and application pages is the way they are parsed by the SharePoint platform. Application pages behave like any other ASP.NET page in that they can contain inline server-side code; however, site pages are rendered using the safe mode parser that prevents inline server-side code from executing. 

  • The client object model has three variants:
             1) JavaScript Client Object Model
             2) Silverlight Client Object Model

                          Microsoft.SharePoint.Client.Silverlight.dll
                          Microsoft.SharePoint.Client.Silverlight.Runtime.dll

             3) Managed Client Object Model:
                  This version has been designed for use by .NET-managed applications
                          Microsoft.SharePoint.Client.dll
                          Microsoft.SharePoint.Client.Runtime.dll


Communication from the client-side object to the server-side counterpart is accomplished via a new Windows Communication Foundation (WCF) service called
Client.svc, as the following illustration shows:





HTML

Script:

JS