Pages

Showing posts with label SharePoint 2007 Administration. Show all posts
Showing posts with label SharePoint 2007 Administration. Show all posts

Thursday, 28 February 2013

Configure People Picker for Multi-Domains(or Cross Domains), Forests Environments - SharePoint 2007 and SharePoint 2010

Excellent post by Salaudeen Rajack to

Configure People Picker for Multi-Domains(or Cross Domains), Forests Environments

 
 

Tuesday, 12 February 2013

When opening office (word, excel) documents from anonymous Internet facing site hosted on SharePoint 2010, users receive logon prompts

Scenario: 

When using IE and opening office (word, excel) documents from anonymous access enabled Internet facing site hosted on SharePoint 2010, users receive logon prompts. After hitting the escape key a couple of times the document does open. When using Firefox the logon prompt does not appear.

Reason:

IE opens word first and then word tries to download the document, however other browsers download the document and then open word to view the document.

According to the Microsoft Knowledge base article, giving "OpenItems" permission allows anonymous users to have view source rights to certain files that could potentially contain sensitive info.



Programmatically give "OpenItems" permission to the SPWeb to anonymous users. Note that you should only do this if you understand & accept the security implications. The sample script below can be used to add the "Open Items" permission:

[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")

$siteUrl = "http://URL_of_your_SITE";
$site = New-Object Microsoft.SharePoint.SPSite($siteurl);
$web = $site.OpenWeb();

$enumPerms = [Microsoft.SharePoint.SPBasePermissions];

Write-Host $web.AnonymousPermMask64;
$web.AnonymousPermMask64 = $web.AnonymousPermMask64 -bor $enumPerms::OpenItems
$web.Update();
Write-Host $web.AnonymousPermMask64;

$web.Dispose();
$site.Dispose();



In my case this did not work, so I had to change the approach to pass the relative path to the document to /_layouts/download.aspx

 Added this script to the Scripts.js (custom Javascript library for my SharePoint site) and called the method in $(document.ready.....


function rectifyOfficeDocumentLinks()
{
     $("a").each(function(){
                if (this.href.match(/.doc$/i) || this.href.match(/.docx$/i) || this.href.match(/.rtf$/i) || this.href.match(/.xls$/i) || this.href.match(/.xlsx$/i) || this.href.match(/.ppt$/i) || this.href.match(/.pptx$/i))
                {
                    if (this.href.indexOf("/_layouts/download.aspx?SourceUrl=") == -1)
                    {
                     this.href = _spPageContextInfo.siteServerRelativeUrl + "/_layouts/download.aspx?SourceUrl=" + this.href.replace("http://" + window.location.host,''); 
                    }
                }
                });
}


References:
  • http://social.msdn.microsoft.com/forums/en-SG/sharepointgeneralprevious/thread/62381802-20b9-49ee-985b-8d2dcd2453ea 
  • http://support.microsoft.com/kb/2498047/en-us
  • http://blogs.technet.com/b/acasilla/archive/2011/10/01/add-openitems-permission-to-the-default-anonymouspermmask64-so-that-you-can-open-office-docs-within-an-anonymous-accessible-sharepoint-site.aspx

Thursday, 25 October 2012

Adding and Deploying solutions in SharePoint 2010

*** When a wsp is available ***

Adding a solution to the Solution Store

Add-SPSolution -LiteralPath <SolutionPath>

Deploy a solution

Install-SPSolution -Identity <SolutionName> -WebApplication <URLname>

To deploy a solution package to all Web applications

Install-SPSolution -Identity <SolutionName> -AllWebApplications -time <TimeToDeploy> -GACDeployment -CASPolicies


To upgrade an existing wsp solution file

Update-SPSolution –Identity mySolution.wsp –LiteralPath c:\mySolution.wsp –GACDeployment

To uninstall a solution

Uninstall-SPSolution –Identity mySolution.wsp –WebApplication http://webapp

To remove a solution

Remove-SPSolution –Identity mySolution.wsp

Extract a solution from the Content DB: SharePoint 2010

In order to gain access to a copy of a wsp file from the Config DB, follow these steps:

Powershell:

$farm = Get-SPFarm
$file = $farm.Solutions.Item("mySolution.wsp").SolutionFile
$file.SaveAs("c:\temp\mySolution.wsp")

To Get all solutions within a farm:
(Get-SPFarm).Solutions | ForEach-Object{$var = (Get-Location).Path + "\" + $_.Name; $_.SolutionFile.SaveAs($var)}

 

C#

using Microsoft.SharePoint
using Microsoft.SharePoint.Administration

namespace GetWSPFile
{
   class GetFile
   {
      static void Main(string[] args)
      {
           SPSolutionCollection AllSolutions = SPFarm.Local.Solutions;
           foreach (SPSolution solution in AllSolutions)
           {
              if(solution.Name =="mySolution.wsp")
              {
                     SPPersistedFile wspFile = solution.SolutionFile;
                     wspFile.SaveAs("C:\" + Solution.Name);
              }
           }
       }
    }
}

Installing a Feature when you only have access to the Feature Folder on the Server: SharePoint 2010

*** When you only have access to
the Feature folder ***
  • First, Copy the folder to the web front end / Central Admin server
Install to the farm:
Install-SPFeature FeatureFolderName

Enable at a site collection
Enable-SPFeature FeatureFolderName -Url http://server/site/subsite

Uninstall a featrure based on a folder:

Uninstall-SPFeature FeatureFolderName
Disable a feature for a site collection
Disable-SPFeature FeatureFolderName -Url http://server/site/subsite

Wednesday, 24 October 2012

How to get the list ID and Content type ID in sharePoint 2010

To get the List ID:
  1. Navigate to list settings and copy List={ENCODED GUID}

    In my case it was this List=%7B2E5002B0-EDC3-4541-A0ED-2A81797B459C%7D
  2.  Decode the GUID here or here
  3. It should return a value similar to this: List={2E5002B0-EDC3-4541-A0ED-2A81797B459C}
That's it :)

To get the Content type ID currently associated with a list or library:

(Assuming allow management of content types is set to Yes (Under list settings > advanced settings))
  1. Navigate to list/library settings
  2. Under content types > select the content type
  3. From the URL copy this part:
    ctype=0x0100801F054C4E00C243A9A49EC13FF778D7003293EF8DE37E144BAA8A5296D5E6CA8B
  4. This the Content type ID

Monday, 28 February 2011

SharePoint 2007 Tips and Tricks

My First blog:
What better way to start of by posting a few SharePoint 2007 (MOSS) tips and tricks.

--> -->
Tip #1: Add Command Line Shortcut to "12 Hive"
When you're in a command prompt, sometimes you need to navigate to the 12 Hive directory. But no one wants to type the directory path to c:\Program Files\Common Files\Microsoft Shared\web server extensions\12. Wouldn't it be easier if you could just type the following to get there?
c:\>cd\
c:\>cd %12hive%
c:\Program Files\Common Files\Microsoft Shared\web server extensions\12
The other thing is you want to be within a Visual Studio Command Prompt to have easy access to things like SN.EXE and GACUTIL.EXE. A VS Command Prompt is nothing more than a simple batch file.
Create a new file called SharePointCommandPrompt.cmd and insert the following text in it (if you're on a 64 bit system, you'll want to make the appropriate changes):
@echo off
echo Setting 12HIVE environment variable.
set 12HIVE="C:\Program Files\Common Files\Microsoft Shared\web server extensions\12"
"C:\Program Files\Microsoft Visual Studio 8\VC\vcvarsall.bat" x86
  1. After saving the file, create a new shortcut with the following target:
%comspec% /k ""c:\[Path To The File You Just Created]\SharePointCommandPrompt.cmd""
  1. To put a cherry on top, drag the shortcut onto your Quick Launch toolbar... should work like a champ!
To try it out, click the shortcut and type CD %12HIVE% at the command prompt. You should change directories to the root of the 12 Hive.
Tip #2: Access STSADM.EXE From any Directory in a Command Prompt
STSADM.EXE, the main administration utility for SharePoint, is still just a command line utility. You'll find it in %12HIVE%\BIN. To run it, you have to actually be in that directory... an inconvenience to me! Instead, add the directory to the PATH environment variable so you can type STSADM.EXE from any directory on your system. To do this:
  1. Start -> All Programs -> Control Panel -> System
  2. On the Advanced tab, click the Environment Variables button.
  3. Select the variable Path and click the Edit button.
  4. Add the following to the end of the Variable value field (don't forget the semicolon... the Path environment variable is a semicolon delimited string of directories):
    ;C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN
  5. OK out of all the dialogs.
Next time your system restarts, you'll be able to type STSADM.EXE at a command prompt from any directory on your system.
Tip #3: Recycle Application Pools, not IIS
So many things in SharePoint require you to recycle the the W3WP.EXE process running SharePoint in order for certain changes to be picked up. So many people think this means recycling IIS by typing IISRESET. But it takes so long for IIS to recycle!
Did you know you don't have to recycle IIS most of the time, just the application pool your site is running within? For development purposes, run all SharePoint sites off the same app pool. Though, not the most secure, but each app pool consumes roughly 100MB of memory so why have a ton of them floating around in a virtual machine when memory is precious!
Instead of recycling IIS, I create a shortcut that I add to my Quick Launch that recycles the app pool all my sites run under. To do this, create a new shortcut on your desktop and enter the following target:
%windir%\system32\cscript.exe c:\windows\system32\iisapp.vbs /a "[Name of your App Pool]" /r
Click the shortcut and watch how fast an app pool is recycled compared to IIS!