About Me

Having 12 years experience in Microsoft technologies.Since more than 7 years working in SharePoint technologies. Expert in providing consultation for SharePoint projects. Hands on with development and administration.
Showing posts with label 2013. Show all posts
Showing posts with label 2013. Show all posts

Monday, 30 January 2017

Get SharePoint site collection URL based on title in SharePoint - server side object model



Pass web application object to the method and return site collection URL 

private string GetSysGlobalSiteUrl(SPWebApplication webApplication)

        {

            string siteUrl = string.Empty;

                     string GLOBAL_SITE_TITLE = “some name”; 

            try

            {

                SPSiteCollection siteCollection = webApplication.Sites;

 

                foreach (SPSite site in siteCollection)

                {

                    SPWeb web = site.OpenWeb();

 

                    if (web.Title == GLOBAL_SITE_TITLE)

                    { 

                        siteUrl = web.Url.ToString();                                               

                       

                    }                  

                }

            }

            catch(Exception ex)

            {

               

            }

            return siteUrl;

        }

Friday, 27 January 2017

How to connect to Oracle DB from Visual studio using ODP.NET (Oracle.ManagedDataAccess.dll)


Oracle introduced new dll to connect Oracle database from .NET.

  1. Down load latest ODP.net package from oracle site. You should download the correct version of package based on your visual studio version
  2. You can check the link for the right version
     
  3. After install you can find the Oracle.ManagedDataAccess.dll @
    D:\xxxxxxxxx\product\12.1.0\client_1\odp.net\managed\common\Oracle.ManagedDataAccess.dll
     
  4. Add the dll as a reference to your project solution in Visual studio.
  5. using Oracle.ManagedDataAccess.Client;

Thursday, 23 July 2015

Set up the SharePoint 2013 Online Management Shell environment

SharePoint Online global administrators use the SharePoint Online Management Shell to remotely manage site collections, upgrade site collections to a new version, configure SharePoint Online company-level settings, and get logs from data connections between SharePoint Online and other services through Business Connectivity Services.
 
To set up the SharePoint Online Management Shell environment, follow these steps:
 
1.Install Windows Management Framework 3.0 from http://www.microsoft.com/en-us/download/details.aspx?id=3459
 
2.Install SharePoint Online Management Shell.http://www.microsoft.com/en-us/download/details.aspx?id=35588

3.From the Start button, choose All Programs, and then select SharePoint Online Management Shell.

4.Run Connect-SPOService.
Connect-SPOService -Url
https://xxxxxx-admin.sharepoint.com -credential admin@yourdomain.com
 Where URL is the URL of the SharePoint Online Administration Center

5.Credential is the user name to which you want to grant access to the SharePoint Online Administration Center site.

6.Try it out! Run Get-SPOSite to get a list of all the sites.

Wednesday, 11 December 2013

PowerShell script to deploy Farm solution - single click - SharePoint 2010, 2013

Here is the Power Shell script to deploy any kind of SharePoint farm solution.

Note: 
1.  Make sure that, your solution should be in the same directory from where you are running the script.

2. Replace your own solution name @ line # 5

3. Pass necessary parameters to Install-SPSolution command.

4. Save file with .ps1 as extension. Example: psDeploy.ps1

5. Create .bat file and call the .ps1 file in it. Example : Deploy.bat

cd /d %~dp0
powershell -noexit -file    ".\
psDeploy.ps1" "%CD%"
pause


6. Once done, directly run the .bat file. No need of launching PowerShell console to execute.

-----------------------------------------------------------------------------------------------------------
Add-PsSnapin Microsoft.SharePoint.PowerShell

Write-Host 'Poweshell Script will initialize parameters'

$CurrentDir=$args[0]

# Replace respective solution

$solutionName="sp.web.webparts.wsp"

$SolutionPath=$CurrentDir + "\"+$solutionName

$logfile=$CurrentDir + "\log.log"

Start-Transcript $logfile

$errorActionPreference = 'Inquire'

# As we are performing deploy and redeploy solutions in single click we will get a known exception which is not requires to handle
# so that we can continue the next statement.

$solution = Get-SPSolution $solutionName  -ErrorAction SilentlyContinue
 
try
{
   
if ($solution -ne $null)
{
if($solution.Deployed)
{

try
{

# Gets the feature attrbutes to log the feature Id information
# $feature= Get-SPFeature -Identity $featureName

# Write-Host 'Powershell Script will now disable feature:' $feature.Id
# Disable-SPFeature -Identity $featureName -Confirm:$false -force

}

# Display and log the feature deactivation failure message with feature Id
catch [SPException]
{
Write-Error 'An error occured while deactivating the feature' $featureId.Id
}

Write-Host 'Poweshell Script will now retract solution:' $solutionName

Uninstall-SPSolution -Identity $solutionName -AllWebApplications -Confirm:$false      

Write-Host 'Poweshell Script is waiting for administrative timer jobs to complete...'

while ($Solution.JobExists)
{  
  Start-Sleep 2   

}

Write-Host 'Poweshell Script will now remove solution:' $solutionName

Remove-SPSolution -Identity $solutionName -Confirm:$false

}

Write-Host 'Poweshell Script will now add solution:' $solutionName

Add-SPSolution $SolutionPath

Write-Host 'Poweshell Script will now deploy solution:' $solutionName

Install-SPSolution -Identity $solutionName -GACDeployment -AllWebApplications

Write-Host 'Poweshell Script is waiting for administrative timer jobs to complete...'

while ($Solution.JobExists)
{  
  Start-Sleep 2   
}

Write-Host 'Poweshell Script has finished deployment of solution:' $solutionName
}

# We can get an unknow error while deploying/redeploying the solution
# so need to dispaly and log the exception details
catch [system.Exception]
{
Write-Error 'An Unknown error occured while trying to deploy/redeploying the solution:' $_.Exception.Message
}

Stop-Transcript

Remove-PsSnapin Microsoft.SharePoint.PowerShell

------------------------------------------------------------------------------------------------------------

Tuesday, 13 August 2013

Web application and site collection improvements in SP 2013

Two important improvements in SharePoint 2013 include a change of Microsoft’s recommendation that web applications should use claims-based authentication by default, and the use of host-named site collections.

Authentication 

·         As with SharePoint 2010, with SharePoint 2013 you can create web applications to use either classic or claims-based authentication.
·         With either type of web application, claims authentication is used for authentication flow within the farm.
·         SharePoint 2013 has extended claims-based authentication via OAuth 2.0 and a dedicated server to- server STS authentication, which together make it possible for your organization to use new scenarios and functionality for Exchange Server 2013, Lync Server 2013, apps in the SharePoint Store or App Catalog, and other services that are compliant with the server-to-server authentication protocol.
·         SharePoint 2013 supports user authentication based on the following claims-based authentication methods:
-Windows claims
-SAML-based claims
-Forms-based authentication claims

When using the Central Administration website, only claims-based web applications can be created. Classic-based authentication is now deprecated, and to create classic-mode web applications, you must use Windows PowerShell. If you are upgrading from SharePoint 2010 to SharePoint 2013, you can convert your classic-mode web applications to claims-based before upgrading.

Host-named site collections 

·         Microsoft recommends that you create host-named site collections (HNSC) and not path-based site collection addressing.
·         HNSC is a mechanism for consolidating web applications into individual site collections, yet letting them retain their existing URLs.
·         In SharePoint 2010, web applications contained one or more site collections and the common practice was to create them under wildcard-managed paths such as http://intranet.adventure-works.com/sites/hr or http://intranet.adventure-works.com/sites/it.
·         Using HNSC, each site collection can have its own top-level URL, so the equivalent site collection could be http://hr.adventure-works.com or http://it.adventure-works.com. Both of these site collections are created in the same web application and could be stored in the same content data.
·         The web application that hosts the HNSC must have a default site collection at its root but does not need a template assigned to it, because it will not be used for anything. Also, for each HNSC you must update the DNS to point to the IP address for the web application that is hosting them or use a wildcard DNS entry.

However, there are still some limitations to this approach

·         HNSC cannot be extended or mapped. You need to set a different set of policies as per the URL.
·         HNSC should not be hosted in multiple web applications. Although this is technically possible, it is complicated to achieve and manage.
·         You should consider perhaps using HNSC in one web application, even though you can create HNSC and path-based site collections on the same web application that you use path-based site collections in other web applications.
·         And, of course, it is very unlikely that you would use HNSC for personal sites.
·         HNSC cannot be created within Central Administration; you must use Windows PowerShell and you need to configure the DNS to send all requests for http://*.adventure-works.com to a web application.
·         This web application must be extended with SharePoint and should not be bound to any specific host headers so that it handles all requests. 

Self-Service Site Collection Creation

·         As with SharePoint 2010, you can enable Self-Service Site Collection Creation (SSC) in SharePoint 2013 with which you can do the following:
·         Allow users to create site collections by using the site collection signup page, scsignup.aspx.
·         Provide users with a shortcut to create new Team sites at a defined location.
·         When you select to prompt users to create either a Team site or a site collection, you can configure Site Classification Settings to be hidden from users, to be an optional choice, or to be a required choice.