Wednesday, July 31, 2013

SharePoint Pre-Upgrade Checker Fails on database diagram!!

This is the kind of stuff that drives you crazy.  SQL Server has supported a simple tool to
diagram databases for years.  Now there are better tools out there but I like the fact that it sits right inside SQL Server Management Studio and helps me visualize my data as I design.

NOTE:  Don't even try to do this on a content database as the preupgrade check will see the
extra tables and sprocs this creates as a schema change and flag your MOSS 2007 DB as not
worthy of an upgrade to 2010.

Thanks to http://selfinflictedsharepoint.blogspot.com/2010/06/sharepoint-pre-upgrade-checker-fails.html


Here are the details:

To correct the error, and allow the Pre-Upgrade Checker to run successfully, we
performed the following:
 We backed up the SharePoint_Content Database before making any changes.  This
  is critical in case something goes wrong.
   I deleted the dbo.sysdiagrams table from Content_Database -> Tables -> System
  Tables
   I deleted the following stored procedures from Content_Database –>
  Programmability -> Stored Procedures -> System Stored Procedures
   sp_upgraddiagrams
   sp_helpdiagrams
   sp_helpdiagramdefinition
   sp_creatediagram
   sp_renamediagram
   sp_alterdiagram
   sp_dropdiagram
   The screenshot  below illustrates these a little better.

Tuesday, July 30, 2013

STSADM to create site



@SET STSADM="c:\program files\common files\microsoft shared\
             web server extensions\12\bin\stsadm"

%STSADM% –o CreateSite –url http://localhost/sites/Sales
                         -ownerlogin LitwareServer\BrianC
                         -owneremail brianc@litwareinc.com
                         -sitetemplate STS#0

*If you omit the -sitetemplate argument, the initial load of the site will prompt you for a template selection.


The following table shows the values for the default site definitions that are included in an installation of Microsoft SharePoint Foundation. (2010)
ValueSite Definition
STS#0Team Site
STS#1Blank Site
STS#2Document Workspace
MPS#0Basic Meeting Workspace
MPS#1Blank Meeting Workspace
MPS#2Decision Meeting Workspace
MPS#3Social Meeting Workspace
MPS#4Multipage Meeting Workspace


BLOG#0Blog
SGS#0Basic Group Work Site
SGS#1Blank Group Work Site
WIKI#0Wiki
http://msdn.microsoft.com/en-us/library/ms472488.aspx
http://technet.microsoft.com/en-us/library/cc287992(v=office.12).aspx

Friday, July 26, 2013

Creating site collection templates

  1. To add the template to central administration site templates you will need to use stsadm. I recommend that you add the path to the bin directory containing stsadm.exe to the system environment variables.
  1. C:\source\site-templates>stsadm -o addtemplate -filename “project-simple.stp” -title “Project site – simple” -description “Project site template with a simple structure”
Operation completed successfully.
IIS must be restarted before this change will take effect. To restart IIS, open a command prompt window and type iisreset.


Source: http://blog.gavin-adams.com/2007/07/03/creating-site-collection-templates/

MOSS 2007 - Save site as a template missing

So trying to move some site content around and needed to have the site template option.

Site Actions > Site Settings > Modify All Site Settings > Look and Feel

I went to what I thought was the top of the site collection but there was no option to save the template. 

Fortunately, Shane at Farmer's Almanac had this to say http://msmvps.com/blogs/shane/archive/2006/07/29/moss-2007-save-site-as-a-template-missing.aspx

You can get at the save as template function by going to the URL directly.

So just to make it clear. If your subsite is

http://portal.abc.local/sitedirectory/team/default.aspx

You would go to

http://portal.abc.local/sitedirectory/team/_layouts/savetmpl.aspx

and then you would be able to save the site as a template.

Thursday, July 25, 2013

MVC 4 user/role management on Intranet

Starting out and was trying to get at HttpContext.Current.Identity.Name.  Dug around and found some very helpful blogs

1.) http://stackoverflow.com/questions/1335571/asp-net-mvc-how-to-use-httpcontext-user
 (MVC)                               (ASP.Net)
User.Identity.Name = HttpContext.Current.Identity.Name

Moving SharePoint Content Databases

We have a large (30GB) site collection which needs to move from one drive to the next.
This must be done first in SQL and then using stsadm.

Here are the steps moving the content on the same server drive to drive:

1.) Open SQL Server Management Studio.
2.) Take the content database offline
3.) Physically move the mdf and ldf files from the old drive to the new drive
4.) Now execute this script against master database.
ALTER DATABASE MyDB MODIFY FILE (NAME = PrimaryData, NEWNAME = MyDB );
ALTER DATABASE MyDB MODIFY FILE (NAME = PrimaryData_log, NEWNAME = MyDB _log);
GO

ALTER DATABASE MyDB SET OFFLINE;
GO
-- Physically move the file to a new location.
-- In the following statement, modify the path specified in FILENAME to
-- the new location of the file on your server.
ALTER DATABASE MyDB
MODIFY FILE ( NAME = MyDB_log,
FILENAME = 'F:\MSSQL.1\MSSQL\Data\MyDB _Log.ldf');
GO
ALTER DATABASE MyDB
MODIFY FILE ( NAME = MyDB,
FILENAME = 'F:\MSSQL.1\MSSQL\Data\MyDB.mdf');
GO
ALTER DATABASE MyDB SET ONLINE;
GO

--Verify the new location.
SELECT name, physical_name AS CurrentLocation, state_desc
FROM sys.master_files
WHERE database_id = DB_ID(N'MyDB')
--AND type_desc = N'LOG';
(http://www.sqlservercentral.com/Forums/Topic1341567-1550-1.aspx)

5.) Ensure that the new location has the correct permissions.
The users:
OWNER RIGHTS, SQLServerMSSQLUser must have Full Control
6.) Bring the Database online by using command line
ALTER DATABASE MyDB SET ONLINE;
7.) Central Admin > Application Management > Manage Content Databases
8.) Click Database Name
9.) Database status to ready > OK

--If you want to move it to a new server then
10) Use Stsadm
--Detach from the old SQL server instance
stsadm –o deletecontentdb –url http://yoursiteurl –databasename your_content_db –databaseserver source_SQL_server
--Attach to new SQL server instance
stsadm –o addcontentdb –url http://yoursiteurl –databasename your_content_db –databaseserver target_SQL_server
Move SharePoint Configuration Database

Wednesday, July 17, 2013

Change the storage limits for a site collection


http://technet.microsoft.com/en-us/library/cc263480(v=office.14).aspx

To change the storage limits for a site collection by using Central Administration

  1. Verify that you have the following administrative credentials:
    • You must be a member of the Farm Administrators group.
  2. On the Central Administration home page, click Application Management.
  3. On the Application Management page, in the Site Collections section, click Configure quotas and locks.   (SharePoint Site Management >
  4. Site Collection Quotas and Locks - MOSS 2007)
  5. On the Site Collection and Quota Locks page, ensure that the correct site collection is displayed. If you want to change the site collection, in the Site Collection section, expand the Site Collection list, and then click Change Site Collection. Use the Select Site Collection page to select a site collection.
  6. If the site collection currently uses a quota template, do the following to specify an individual quota:
    • On the Site Collection Quotas and Locks page, in the Site Quota Information section, expand the Current quota template list, and then select Individual Quota.
  7. Leave the Limit site storage to a maximum of check box selected, and then type the new maximum value in megabytes.
  8. If you want to send site storage notification e-mail messages to the site collection administrator, select the Send warning e-mail when site storage reaches check box, and then type the value in megabytes.
  9. If you want to limit the maximum resource usage points per day for sandboxed solutions, type the new limit in the Limit maximum usage per day to box. The default is 300 points.
  10. If you want an e-mail message to be sent to the site collection administrator when the usage per day threshold is reached, select the Send warning e-mail when usage per day reaches check box, and then type the threshold, in points, in the box. The default is 100 points.
  11. Click OK.


To change the storage limits for a site collection by using Windows PowerShell

  1. Verify that you meet the following minimum requirements: See Add-SPShellAdmin.
  2. Click Start, and then click All Programs.
  3. Click Microsoft SharePoint 2010 Products.
  4. Click SharePoint 2010 Management Shell.
  5. At the Windows PowerShell command prompt, type the following command:
    Set-SPSite -Identity "<Site>" -MaxSize <Limit>
    
    Where:
    • <Site> is the URL of the site collection whose storage limits you want to change.
    • <Limit> is the new storage limit for the site collection, in megabytes.
      noteNote:
      The new storage limit overrides the limit set in the quota template that is currently applied to the site collection.

      For more information about the Set-SPSite cmdlet, see Set-SPSite.
    For information about how to use Windows PowerShell and the SharePoint object model to set the maximum usage per day and the warning level threshold for sandboxed solutions, see "Using Windows PowerShell for Administration" in Chapter 4: Sandboxed Solutions (http://go.microsoft.com/fwlink/p/?LinkId=219528), an excerpt from the book Inside Microsoft SharePoint 2010 on MSDN.


Friday, July 12, 2013

Impersonation causes 401 authorization error

Ran into this issue with an existing application which was using webservices on another machine.
The application was making the requests to the service.  Each point where the application made the request the authentication would fail.  This worked fine on the local dev box but failed as soon as it was deployed to IIS.

This is the double hop issue which the articles below refer too:
  1. http://stackoverflow.com/questions/727421/impersonation-and-credentialcache-defaultcredentials-gives-http-401-unauthorized
  2. http://stackoverflow.com/questions/517846/impersonation-and-delegation-in-asp-net

Workarounds recommended are Kerberos or reauthentication.  I decided on another option which was too create a network crendential with a service account in our AD forest.  This is stored in the web.config.(Encrypt the config is always good practice).  Created a method called GetCredentials

string CredID = Configuration.Manager.AppSettings("ID");
string CredPass = Configuration.Manager.AppSettings("Pass");
string CredDomain = Configuration.Manager.AppSettings("Domain");

return System.Net.NetworkCredentials(CredId,CredPass,CredDomain);


Each time you need to call the service just set the services credentials via this method and voila your request will go through each time!