Alexander Anikin's blog

My personal blog

Archive for February 2011

Connect SharePoint to Outlook

leave a comment »

Sometimes it’s good to add SharePoint connection to Outlook from code.

This function can do this using Outlook Interop and MAPI namespace:

using Microsoft.Office.Interop.Outlook;

static void AddSpsFolder(string name, string syncurl)
        {
            Microsoft.Office.Interop.Outlook._Application oApp = new Microsoft.Office.Interop.Outlook.Application();
            _NameSpace oNS = (_NameSpace)oApp.GetNamespace(“MAPI”);
            oNS.Logon(Type.Missing, Type.Missing, true, true);

            bool useDefaultTTL = true;

            Folder oFolder =   oNS.OpenSharedFolder(syncurl, name, Type.Missing, useDefaultTTL)  as Folder;
            Explorer oExp = oApp.Explorers.Add(oFolder, OlFolderDisplayMode.olFolderDisplayNormal);
            oExp.Display();

            oNS.Logoff();

            oApp = null;
          
            oNS = null;
            oFolder = null;
            oExp = null;
        }

Where:

  •  name – folder storage  name;
  • syncurl – stssync path (like stssync://sts/?ver=1.1&type=tasks&cmd=add-folder&base-url=https%3A%2F%2Ftest%2Esp%2Edomain%2Enet&list-url=%2FLists%2FTasks%2F&guid=%7B1a2a4e01%2D25af%2D4cca%2D9175%2D5511d5986d45%7D&site-name=A&list-name=Tasks)

PS: You can use it in console an “runas /profile /env /user …” as different user.

Advertisements

Written by Alex Anikin

February 28, 2011 at 1:48 pm

Posted in Office, Sharepoint

How To Install Root Certificate to SharePoint Server

leave a comment »

Generate .cer file and use PowerShell:

$rootca = New-Object System.Security.Cryptography.x509Certificates.x509Certificate2(“c:\rootca.cer”)
New-SPTrustedRootAuthority -Name “Name Of Root CA” -Certificate $rootca

Written by Alex Anikin

February 28, 2011 at 1:46 pm

Posted in Security, Sharepoint

SQL Server Database in Suspect Mode

leave a comment »

I had a strange issue on one of my old SQL Server 2005 Express.

My application database was marked as SUSPECT.

My great fault was no backups and I need solution without great data looses.

Big thanks to CodeProject.

SQL:

EXEC sp_resetstatus ‘yourDBname’;
ALTER DATABASE yourDBname SET EMERGENCY
DBCC checkdb(‘yourDBname’)
ALTER DATABASE yourDBname SET SINGLE_USER WITH ROLLBACK IMMEDIATE
DBCC CheckDB (‘yourDBname’, REPAIR_ALLOW_DATA_LOSS)
ALTER DATABASE yourDBname SET MULTI_USER

Written by Alex Anikin

February 28, 2011 at 1:45 pm

Posted in Databases

Loading Site Template .wsp file

leave a comment »

Shortcut for Site Collection Solutions Catalog for working with templates stored as wsp-file:

http://<site>/_catalogs/solutions/Forms/AllItems.aspx?InitialTabId=Ribbon%2ESolution&VisibilityContext=WSSTabPersistence

There are options: Upload, Activate, Deactivate, Delete.

Written by Alex Anikin

February 1, 2011 at 1:47 pm

Posted in Sharepoint