Sunday, November 24, 2013

Install Gui on Windows 2012 R2

Installed the wim on the vhd and booted into Windows 2012 no issues. 
When I logged in noticed that the GUI was not active.  This was a new
one for me since I have just started working with 2012.  Found this
helpful tip.

1. At the prompt type: powershell
2. Install-WindowsFeature Server-Gui-Shell, Server-Gui-Mgmt-Infra
Wait for it to install
3.shutdown -r -t 0

Now when you reboot you will have the GUI!

Source:
http://www.servethehome.com/windows-server-2012-install-turn-gui-powershell-command-line/

Wednesday, November 6, 2013

MVC4 with jquery-ui datepicker - Microsoft JScript runtime error: 'jQuery' is undefined

Working on a MVC project and making good progress.  Decided to start using jQuery and had real
issues using the datepicker.  Kept getting this error and new it had to be something with the order
and load time. 

Solution:
 1. Open your _layout.cs and add the following just before the closing tag of the </body>
    @Scripts.Render("~/bundles/jquery")
    @Scripts.Render("~/bundles/jqueryui")
    @Styles.Render("~/Content/themes/base/css")
    @RenderSection("scripts", required: false)
2. Finally to test your view, open your index.cshtml and add this at the end
<p>Date:
    <input type="text" id="txtDate" class="datefield" />
</p>

@section Scripts{
    @*@Scripts.Render("~/bundles/jqueryval")*@
    <script type="text/javascript">
        $(document).ready(function () {
            $(".datefield").datepicker();
        });
    </script>
}
 
source:

Wednesday, October 16, 2013

InfoPath posting anonymously

This theme seems to come up a lot. I did some cursory searching based on a user's request
to allow anonymous users to post to a document library.

  1. http://tim-sharepoint.blogspot.com/2008/10/sharepoint-anonymous-infopath-forms.html
  2. This solution is a more classic approach using the code behind in VSTA.  This allows us to encapsulate the request with a service account to make the submission for the anonymous user.

  3. http://claytoncobb.wordpress.com/2011/06/03/infopath-allowing-anonymous-users-to-submit-forms-in-sharepoint-2010/
    This solution relies on InfoPath 2010 tight integration and expanded capabilities of SP 2010 Enterprise.
  4. http://sshela.wordpress.com/2011/05/13/how-to-enable-anonymous-access-to-a-infopath-forms-library/

Thursday, October 10, 2013

Javascript blocks in webparts not working in SharePoint 2010.

Difference between RegisterStartupScript and RegisterClientScriptBlock?

Ouch, this took me by surprise.  I have been fighting with two webparts which were migrated from 2007 to 2010.  They used some simple javascript to change div tag blocks from none to display.  They worked great in 2007 but failed in 2010. 

Issue:
Div tags and javascript functions are inserted into page where the webpart was hosted.  The onclick events would fire but not find the function references.  Thus the div tag functionality did not work in 2010.

Solution:
In the onload event changed Page.ClientScript.RegisterClientScriptBlock  to Page.ClientScript.RegisterStartupScript.

Explanation:
During the onload event of the webpart, the Page.ClientScript.RegisterClientScriptBlock was used to insert the javascript into the page.  This puts the code base at the top of the page right after the viewstate variables.  This is also where all of the 2010 ribbon controls are at.  This collision was the reason the webparts could not see the javascript blocks.  Changing the Page.ClientScript.RegisterClientScriptBlock to Page.ClientScript.RegisterStartupScript puts the script block after all the elements and right before the close form tag.

Source:
http://stackoverflow.com/questions/666519/difference-between-registerstartupscript-and-registerclientscriptblock

Tuesday, October 8, 2013

Webpart deployment gives error - Could not load file or assembly '' or one of its dependencies

I was trying to upgrade 2007 webpart to 2010.  I used the VS empty sp template and added my features and webpart.  I use the argotic libraries to support rss feeds.  These 3rd party dependencies had been added into the project and it compiled and deployed.  After each deployment, I would try and use the webpart and it would fail each time my part tried to hit any of those dlls.  I could not figure why this was not working.  I had the controls deployed to the GAC but was still getting the error.  Then I ran across this post (http://stackoverflow.com/questions/8406037/could-not-load-file-or-assembly-or-one-of-its-dependencies).

Solution:
Add the dependencies to the package deployment and then you are guaranteed to always have the dlls you need.  In your SharePoint 2010 project,
  1. Open Package.package from Package folder in SharePoint project.
  2. Click Advanced in bottom area.
  3. Click Add and chose which type of assembly you want to add.
  4. In dialog select dll file, chec GAC or BIN, add safe controls and class resources entries if required. Click Ok.

Monday, September 30, 2013

SP 2010 Publishing Sites Without Workflows

We just did the upgrade on an old 2007 site to get it up to 2010.
We had a pages library which required user's to go through the approval
process just to publish!  Egads lots of pain for our users. 

Thanks to the grumpy guru at Publishing Sites Without Workflows

Solution:
Navigate to the Pages library (View all site content for example). Click on the Library tab then Library Settings. Under General settings, click on Versioning settings. For “Require content approval for submitted items?” select the No radio button. That’s it!

Wednesday, September 18, 2013

Visual Studio 2010 Maint: Path to installation not available.

This error seems to bite a lot of devs.  I have a box with full SQL 2008 and VS 2010 installed.  Each time I tried to add in a new feature to the existing install it fails.  I dug around the temp dir and looked at the log.

In Error log:

VS70pgui: ***ERRORLOG EVENT*** : Unable to retrieve the install directory for Microsoft Visual Studio Performance Collection Tools for v4.0 in COptionsPage::IsGoodAllComponenentsPath


Not sure what was causing this until I stumbled upon this post http://edeevans.wordpress.com/category/development-tipstricks/

Problem:
I believe this may be due to having installed SQL Server 2012 Developer Edition which uses a stand-alone install of Visual Studio 2010. I say this because while solving the issue by uninstalling SP1, I was prompted for the MSI for vs_setup.msi. I was puzzled by this until I looked closer at the prompt which mentioned Stand Alone and that jogged my memory of the SQL install. The SQL Management Studio will use a stand-alone install of the previous version of Visual Studio. So SQL 2010 uses Visual Studio 2008 and SQL 2012 uses Visual Studio 2010. At any rate, I had to mount the ISO for SQL Server 2012 and point it at the proper location to complete the uninstall of SP1.

Solution:
Remove SP 1 since I can't remove SQL Server.  This resolved the issue.  Then I reapplied SP1.

Tuesday, September 17, 2013

IIS application can't connect to database with account DOMAIN\MachineName$

Problem:
Have a UAT box which runs Win 2008 R2, IIS 7.5.  Have anonymous authentication disabled and both ASP.Net impersonation and windows authentication enabled.  Application is connecting to remove sql server which is using windows only authentication and has ssl enabled.  We have created a forest level service account to connect between IIS and SQL.  This should work but keep getting access errors on SQL saying that account DOMAIN\MachineName$ does not have access to sql server.  I really was not sure what was happening since I have set up impersonation and knew that the service account was correct and had dbo roles in the database.  The issue turned out to be the application pool identity on IIS for this application.  It was set to use the default local network account on IIS.  This has no access to the SQL box.  I set the app pool identity to the service account and restarted iis.  It now connects and passes through the sql requests without error. 


Solution:
1.) in IIS : set up impersonation in IIS application.  Disable anonymous auth. Require windows logon. Set the impersonation account to use the service account
2.) in SQL: add required dbo roles to the service account
3.) Check the IIS app pool identity
The issue turned out to be the application pool identity on IIS for this application.

Monday, September 16, 2013

WCF service hosted in IIS 7 returning error "Security settings for this service require 'Anonymous' Authentication but it is not enabled for the IIS application that hosts this service"

This seems to be a pretty common error.  See the below discussion on msdn,
http://social.msdn.microsoft.com/Forums/vstudio/en-US/9e60fd61-aa84-453a-b340-8e1334d7acc9/wcf-service-hosted-in-iis-7-returning-error-security-settings-for-this-service-require-anonymous.  There was a lot of talk about setting IIS to anonymous and letting it go at that.  This would ignore the whole binding process for WCF.

My particular problem was that my IIS site hosted was locked down to Windows authentication due to the application requirements.  We are communicating with a database via this application and can not allow anonymous access due to security restrictions.  We still needed to run a WCF service to do the actual communication with the database to our mid tier.  This can be done but you need to set the binding for the service correctly.

Solution:

You need to define the security for the WCF service in the configuration bindings

Sample:

<system.serviceModel>
  <services>
       <service name = "WorkflowService" behaviorConfiguration="serviceBehavior">
            <host>
               <baseAddresses> <add baseAddress=https://yourserver /> </baseAddresses>
            </host>
         <endpoint name = "BasicHttpEndpoint"
                           binding = "basicHttpBinding"
                           bindingConfiguration = "WorkflowBinding"
                           contract = "IWorkflowService"
                           behaviorConfiguration="WorkflowEndpointBehavior">
         </endpoint>
       </service>
  </services>

This sample defines my service which will need to be "anonymous" to invoke the service on an SSL windows IIS site.  The key is in the definition of bindingConfiguration.  This sample service would need the binding defined so:

<bindings>
      <BasicHttpBinding>
             <binding name="WorkflowBinding" receiveTimeout="00:30:00" sendTimeout="00:30:00"
               maxReceivedMessageSize="2147483647"/>
              <security mode="Transport">
                          <transport clientCredentialType="Windows"
                            proxyCredentialType="UserName"
                            algorithmSuite="Default"/>
              </security>
            </binding>
      </BasicHttpBinding>
</bindings>


Set the security mode to transport and specify the credentialtype as windows.  This is the key to getting past this error. 

clientCredentialType

clientCredentialType
  • Specifies the type of credential to be used when performing client authentication using HTTP authentication. The default is None. This attribute is of type HttpClientCredentialType.
proxyCredentialType
  • Specifies the type of credential to be used when performing client authentication from within a domain using a proxy over HTTP. This attribute is applicable only when the mode attribute of the parent security element is Transport or TransportCredentialsOnly. This attribute is of type HttpProxyCredentialType.
Source:
http://msdn.microsoft.com/en-us/library/ms731334(v=vs.100).aspx


security mode

Member nameDescription
Supported by Portable Class LibraryNoneThe SOAP message is not secured during transfer. This is the default behavior.
Supported by Portable Class LibraryTransportSecurity is provided using HTTPS. The service must be configured with SSL certificates. The SOAP message is protected as a whole using HTTPS. The service is authenticated by the client using the service’s SSL certificate. The client authentication is controlled through the ClientCredentialType.
MessageSecurity is provided using SOAP message security. For the BasicHttpBinding, the system requires that the server certificate be provided to the client separately. The valid client credential types for this binding are UserName and Certificate.
Supported by Portable Class LibraryTransportWithMessageCredentialIntegrity, confidentiality and server authentication are provided by HTTPS. The service must be configured with a certificate. Client authentication is provided by means of SOAP message security. This mode is applicable when the user is authenticating with a UserName or Certificate credential and there is an existing HTTPS deployment for securing message transfer.
Supported by Portable Class LibraryTransportCredentialOnlyThis mode does not provide message integrity and confidentiality. It provides only HTTP-based client authentication. Use this mode with caution. It should be used in environments where the transfer security is being provided by other means (such as IPSec) and only client authentication is provided by the infrastructure.

source:http://msdn.microsoft.com/en-us/library/system.servicemodel.basichttpsecuritymode(v=vs.100).aspx


           



Thursday, September 5, 2013

Error message when you try to uninstall SharePoint Foundation 2010 or SharePoint Server 2010: "Microsoft SharePoint 2010 uninstall did not complete successfully"

This one drove me crazy.  Most people can solve the error with these two fixes:

  1. http://davidlimsharepoint.blogspot.com/2010/08/microsoft-sharepoint-server-2010.html
  2. http://support.microsoft.com/kb/981228
Unfortunately, mine was more esoteric.  The real issue was not a registry setting but a failed SQL Express install!

Dug out from my logs:

Can't uninstall Sharepoint Server 2010 - Error: Command: dbwrap.exe' failed with error code: -2068643838. Type: 8::CommandFailed.

Solution:

Uninstall the SQL Server Express !

http://social.technet.microsoft.com/Forums/sharepoint/en-US/7caf3aa0-b3c8-4a52-af7f-1527eee52828/cant-uninstall-sharepoint-server-2010-error-command-dbwrapexe-failed-with-error-code

How to uninstall an existing instance of SQL Server 2008 R2

Had an issue with a box with multiple SQL instances installed and needed to remove 2 instances.
I tried to use the SQL install msi but it does not include the tool to remove an existing instance.
I stumbled across this link http://msdn.microsoft.com/en-us/library/ms143412(v=sql.105).aspx.

I thought I would capture the steps visually since the description sometimes does explain where in the GUI the "magic" button is.


1.) Start > Control Panel > Uninstall a Program.  Select the Microsoft SQL Server 2008 R2 Package

 
2.) The next window select Remove

3.) Let the setup rules screen run and click ok.


4.) Select the instance you want to remove
 

5.) Select the features to remove.  Take care not to remove the Shared items as these are used by the other instances of SQL Server on the box.

6.) Select Remove and let the process complete.
 


 
7.) Success






Tuesday, September 3, 2013

MVC with Sproc and POCO

Looking at MVC for a new project and saw a lot of examples with LinqToSQL and EF.
What I wanted to look at was using MVC with an existing database design with existing
sprocs and views.  Dung's tutorial is using MVC 3 but with some tweaking I was able to
use MVC 4 and an existing db design.

Just finished working through this sample.  And it helped me out.
http://nndung179.wordpress.com/2012/04/10/mvc-3-and-stored-procedure-part-1/

Friday, August 30, 2013

PowerShell vs stsadm in SharePoint 2010 - Solution Deployment

  • Add solution
  • stsadm –o addsolution –name SharePointProject2.wsp
  • Add-SPSolution c:\code\SharePointProject2\bin\debug\SharePointProject2.wsp

  • Deploy Solution
  • stsadm –o deploysolution –name SharePointProject2.wsp –url http://moss-server –allowCasPolicies –immediate
  • Install-SPSolution –Identity SharePointProject2.wsp –WebApplication http://sp2010 -GACDeployment


  • Upgrade Solution
  • stsadm –o upgradesolution –name SharePointProject2.wsp –filename SharePointProject2.wsp –immediate –allowCasPolicies
  • Update-SPSolution –Identity SharePointProject2.wsp –LiteralPath c:\code\SharePointProject2\bin\debug\SharePointProject2.wspGACDeployment

  • Remove Solution.
  • Uninstall-SPSolution –Identity SharePointProject2.wsp –WebApplication http://sp2010
  • Remove-SPSolution –Identity SharePointProject2.wsp


Source:
http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2009/12/02/adding-and-deploying-solutions-with-powershell-in-sharepoint-2010.aspx

Feature vs. Solution

http://manish-sharepoint.blogspot.com/2010/01/difference-between-solution-and-feature.html

Error occurred in deployment step ‘Activate Features’: Feature with Id ‘’ is not installed in this farm, and cannot be added to this scope.

I am upgrading a RSS reader web part used in our MOSS farm for use in the new 2010 MSF farm.
I had it almost complete but could not get it to deploy and activate without an error.  The error message:

Error occurred in deployment step ‘Activate Features’: Feature with Id ‘<GUID>’ is not installed in this farm, and cannot be added to this scope.”
Would come up each time I deployed the feature.

This issue was driving me crazy until I found Graham Alltoft's post:
- http://alltoft.wordpress.com/2011/06/13/sp2010-error-occurred-in-deployment-step-activate-features/

Solution: 

Use powershell to activate the feature not VS 2010

  • Set the project to No Activation
  • Deploy from Visual Studio again with no activation this time
  • Open powershell
  • Install-SPFeature <yourFeature>
  • Enable-SPFeature <yourFeature> -Url http://yoursite.com

  • or

    In central admin go to the solution management and activate the solution with the GUI

    Tuesday, August 27, 2013

    Content Database Current Site Count is 0

    Upgrading a 2007 SP2 content database to 2010 content database.  Using the Mount-SPContentDatabase shell and having good success.  Ran into this one and was stumped.

    I would submit the command

    Mount-SPContentDatabase SharePoint_Content_01 –databaseserver <servername> -WebApplication <serverurl>

    The result would execute and return the command:

    ID                        : <Guid>
    Name                   : SharePoint_Content_01
    WebApplication  : Web - 80
    Server                  : <SQLServer\SchemaName>
    CurrentSiteCount: 0

    Issue:
    Why would there be 0 sites?  I have at least 10.

    Solution:
    Check the spelling of your content database.  The mount command does not check for the content database.  If it does not exist it will create it for you automatically.

    I purused this site http://sharepoint.stackexchange.com/questions/29719/content-database-shows-no-site-collections and stumbled across this issue.




    Thursday, August 22, 2013

    Adding a Button to the Ribbon in SharePoint 2010

    Create your own Custom Action Group with a Custom Action


    Rather than reinventing the wheel by writing my own set of instructions, please refer to this MSDN article:

    Tuesday, August 20, 2013

    DotPeek .Net decompiler

    I was looking around for a copy of the decompiler and could not find it. 
    The url is
    http://www.jetbrains.com/decompiler/

    This tool will decompile any .net dll from 1.0-4.5!

    Wednesday, August 14, 2013

    Microsoft SQL Server Migration Assistant (SSMA)

    The Upsizing Wizard built into Access does not bring over the "queries" in the Access database.
    I surmise these are the equivalent of stored procedures.  Not sure why the upsizing did not bring this over.  I did find this nice add on from Microsoft which claims to migrate from Access to SQL server.

    Microsoft SQL Server Migration Assistant (SSMA) for Access is a tool to automate migration from Microsoft Access database(s) to SQL Server or SQL Azure

    http://www.microsoft.com/en-us/download/details.aspx?id=28763
    http://blogs.msdn.com/b/ssma/archive/2011/01/28/access-to-sql-server-migration-how-to-use-ssma.aspx

    Migrate from Access to SQL


    NOTE: If you are using Access 97 and higher versions, you can also use the SQL Server Migration Assistant for Access. For more information about the SQL Server Migration Assistant for Access, visit the following Microsoft Web site:

    http://www.microsoft.com/sqlserver/en/us/product-info/migration-tool.aspx#Access


    The easiest way to convert an Access database to SQL Server is to use the Upsizing Wizard. The Upsizing Wizard:
    • Preserves database structure, including data, indexes, and default settings.
    • Automatically converts Access validation rules and default settings to the appropriate SQL Server equivalents.
    • Maintains table relationships and referential integrity after you upsize.


    http://answers.microsoft.com/en-us/office/forum/office_2007-access/export-access-table-schema-to-sql/8a6d1052-86b0-4080-9147-6c2c64ba1d9c

    MSDN downloads without Akami download manager

    I was trying to get some bits off of the MSDN site today and hit the dreaded AKAMI block!

    Our local policies do not permit the installation of Active X controls on our local machines.  Surfing directly to the MSDN site and hitting the download button will either load the Akami manager or prompt you to install the control.  Of course, this fails since we do not have the permissions to load on our local machines.  So what to do??

    The help on MSDN was kind enough to elaborate on the issue

    Direct download option

    Files are also available from Subscriber Downloads using your browser only, rather than any download manager. You may use this option if you prefer downloading with your browser, or if you are unable to run ActiveX-based download managers due to the security or proxy settings at your organization.
    To find the Direct Download link for a particular file, select Details under the filename. From the Permalinks displayed under Details, select Direct Download to start a file download using your browser’s download manager.




    Wednesday, August 7, 2013

    A service application database was deleted in SQL Server Management Studio


    Solution
    Using PowerShell, run the following command:
    Get-SPDatabase | where {$_.exists -eq $false}
    This will list all databases in SharePoint that no longer exist on the database server. If you are happy with the result and wish to remove the orphaned databases, run the following command:
    Get-SPDatabase | where {$_.exists -eq $false} | foreach {$_.delete()}

    Source:
    http://www.mysharepointadventures.com/2012/02/cleaning-up-deleted-databases-in-sharepoint/

    Event 5402, SharePoint Foundation - SeSecurityPrivilege - Tracing Service failed

    Installing a new instance of SharePoint 2010. We will be migrating some 2007 content database using the attach and upgrade method. For now we are just trying to get the box set up and running.

    Using Powershell:
    New-SPConfigurationDatabase -DatabaseName SharePoint_Config -DatabaseServer DBNAME\INSTANCE -AdministrationContentDatabaseName SharePoint_Admin_Content

    I am running powershell as the service account which is installing the application. This account has been granted permissions on SQL (db_creator, security Admin)

    Each time it runs I get flagged with this error:
    Tracing Service failed to create the usage log file at ...\14\Logs. Error 0x0: The process does not possess the 'SeSecurityPrivilege' privilege which is required for this operation.

    Clinton Cherry at Cherry Bytes put me on to the fix for my configuration:

    In order to fix this you will need to do the following:
    Go to > Local Security Policy- > Local Policies -> User Rights Assignment on the server you are trying to install on.
    Assign your logged in account (eg [domain]/[username]) the following rights:
    • Back up files and directories
    • Debug Programs
    • Manage auditing and Security log
    • Restore files and directories
    • Take ownership of files or other objects

    What if your box locks down these policies.

    The SeSecurityPriv is tied to the Manage auditing and Security Log policy.  This was granted to only the members of the local Auditors group.  I added our service account to the auditor's group and rebooted the box.  I then reran the New-SPConfigurationDatabase command and successfully created the Admin and AdminContent dbs.

    Migration Guide SharePoint 2007 to 2010

    This document outlines the setup for a migration from 2007 to 2010
    SharePoint 2010 Installation with Powershell_Sep2012.docx


    Update:  Plenty of good sites on the how tos.  This site lays out
    the steps well

    http://www.sharepointdiary.com/2011/09/migrate-from-moss-2007-to-sharepoint-2010.html

    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!

    Monday, June 24, 2013

    SharePoint list rollup - url references to child lists

    Asked to create a view which rolls up list libraries on subsites to a central parent site list.
    The view needed to list each item link relative to its list and not the parent list url.

    This required use of the XPath functions substring-before/after.  XPath does not define a function
    lastIndexOf or IndexOf.  Would be nice to have these!

    Problem was that though the parent list did provide the url path back to the child list it did not include
    the item ID.  This means you have to parse the url and build the url reference in Xpath.

    Sample:

    URL = fullurl/Lists/LibraryName/Filename

    <xsl:variable name="tempurl" select="substring-after(@fileRef,'Lists/')"/>
    <xsl:variable name="directory" select="substring-before($tempurl,'/')"/>
    <xsl:variable name="url" select="substring-before(@fileRef,'Lists/')"/>

    <xsl:variable name="tasklink" select="concat($url,'Lists/',$directory,'/DispForm.aspx?ID=',@ID)" />

    <a href="{$tasklink}"><xsl:value-of select="@Title"/></a>


    SharePoint Designer, XPath, LastIndexOf,@FileRef

    Wednesday, June 19, 2013

    An Unexpected error has occurred (MOSS 2007)/FIPS issue

    Finished an install of MOSS on a box and tried to bring up Central Admin.
     I received this most informative message! 

    An Unexpected error has occurred

    Step 1:
    First thing to do was to get the actual error message.
     Tweak the web.config in WSS
     1.) Modify the web.config and set debug="false".

    Note: Some blogs mention the work around
    <configuration>
        <runtime>
            <enforceFIPSPolicy enabled=”0” />
            <!-- or maybe ="false" -->
        </runtime>
    </configuration>
    The issue here is that if you need FIPS compliance then you can't just turn off the policy.


    Step 2:
    Now I was getting the actual error - Unable to validate data.  The application log listed Event ID 1309/Event Code 3005.  The key was the validation error.  This lead me to a common error in our environment.

     Issue:
    Group Policy enforced on our servers sets fips policy to 1
    (HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\fipsalgorithmpolicy)

    MOSS 2007 is built on 2.0 of Framework which uses the RijndaelManaged implementation of the AES algorithm when it processes view state data.  The RM implementation has not been certified by the NIST as compliant with the Federal Information Processing Standard (FIPS).  Therefore the FIPS algorithm is not part of the Windows Platform FIPS validated crytographic algorithms.  Enforcing FIPS means that state data in MOSS can't be decypted properly.

    Solution:

    Modify the Machine.config file
    1.) Open machine config at %installdir%/microsoft.net/Framework/v2.0.50727/Config
    2.)Locate <system.web>
    3.)Add following block
    <machineKey validationKey="AutoGenerate,IsolateApps" decryptionKey="AutoGenerate,IsolateApps" validation="3DES" decryption="3DES"/>
    4.)Save machine.config
    5.)iisreset

    Friday, June 14, 2013

    BrownField Code Adventure

    Yippee, I have inherited an application which the customer has asked me to "tweak".  This is an .Net C# application which began life in VS 2005 on IIS 6.  We need to get it too VS 2010 SP1 IIS 7.5.
    Here is what I have experienced so far:

    1.) This was a website solution vice a web application which is my preference when working with these types of applications.  I tried to copy and paste the files over and was reminded of this pit fall.
    • Designer pages which contains all the globals for the controls is not present in a website solution.
    • Markup Header files use the CodeFile vice CodeBehind keyword
    • Namespace was not aligned with the web project name but can be fixed.  That means patch each class with the new namespace for the application.
    2.) String handling using the namespace Microsoft.VisualBasic.Strings!  What happened? String is part of the System namespace most classes inherit the string from the System namespace.

    Here is what I found:
    return Path.Combine(TraceLogsPath, "TraceLog." + Strings.Format(DateTime.Now, "yyyy.MM.dd") + ".xml");

    What is SQL Client Connectivity SDK in SQL 2008 R2 Installer

    During an install I was wondering what this option did?


    SQL Client Connectivity SDK and Client Tools SDK provided the Wrapper objects for COM components.

    Client Tools SDK Provide wrappers classes for DTSRuntime and similar components that you can use to Execute a .dtsx (SSIS) package on demand. Most of the People install Integration Service to perform similar task.

    Also SQL Client Connectivity SDK plays a key role in providing Microsoft.SQLServer.Diganostics.STrace library used by Client Tools.

    Now, you can use this Wrapper classes to run a SSIS package from within your WCF/WebService/Windows Service or any other .Net App without calling a SQL Agent Job.

    there are probably more uses to this library and would be great if someone added to my comment.

    Thanks Pawan Gonnakuti
    http://connect.microsoft.com/SQLServer/feedback/details/381445/sql-client-connectivity-sdk-and-client-tools-sdk-documentation

    Tuesday, June 11, 2013

    Cannot Open User Default Database (error 4064) - SQL database lock out recovery

    In my haste to recreate a database, I neglected to set my account back to the default master.
    Now each time I attempt to login, SQL Server issues error 4064 as it attempts to connect to a
    catalog which is not longer there!

    Fortunately, Laurentiu Cristofor at http://social.msdn.microsoft.com/forums/en-US/sqlsecurity/thread/b32c862a-799c-43c4-a731-c4811078c8bd/

    Had the solution:

    C:\> sqlcmd -E -d master
    1> ALTER LOGIN [BUILTIN\Administrators] WITH DEFAULT_DATABASE=master
    2> GO

    Brownfield coding - Silverlight 4 Toolkit installation vs. Visual Studio 2010 SP1

    Had an opportunity to patch some Silverlight 4 code which we have installed.  Did not have the environment set up and tried to install Silverlight Tools 4 .exe.("Single Install" for Silverlight Developer runtime and the tools.)

    Each time I ran the exe it failed telling me that their was a conflict with my current install.  I snooped around and found several tips guides based around RC version software.  Did finally hit upon the issue which was Visual Studio 2010 SP1.  It conflicts with the version 4 install.  So I removed SP1 from the box and reran the install without issue. 

    Visual Studio 2010 sp1 full iso

    Needed a full copy of the sp1 iso for a disconnected network.

    Microsoft has this link set up for just such a need.

    http://go.microsoft.com/fwlink/?LinkId=210710

    Getting access to locked SQL Server - add a user to the SQL Server sysadmin role

    Had a few developer's who left and did not give access to development databases.  I could not
    access the databases since I had not be designated as one of the sysadmins on their local dbs. 

    I found this script from Microsoft which will add a local system admin account to the SQL sysadmin group.  It worked great for me.


    @echo off
    rem
    rem ****************************************************************************
    rem
    rem    Copyright (c) Microsoft Corporation. All rights reserved.
    rem    This code is licensed under the Microsoft Public License.
    rem    THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
    rem    ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
    rem    IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
    rem    PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
    rem
    rem ****************************************************************************
    rem
    rem CMD script to add a user to the SQL Server sysadmin role
    rem
    rem Input:  %1 specifies the instance name to be modified. Defaults to SQLEXPRESS.
    rem         %2 specifies the principal identity to be added (in the form "<domain>\<user>").
    rem            If omitted, the script will request elevation and add the current user (pre-elevation) to the sysadmin role.
    rem            If provided explicitly, the script is assumed to be running elevated already.
    rem
    rem Method: 1) restart the SQL service with the '-m' option, which allows a single connection from a box admin
    rem            (the box admin is temporarily added to the sysadmin role with this start option)
    rem         2) connect to the SQL instance and add the user to the sysadmin role
    rem         3) restart the SQL service for normal connections
    rem
    rem Output: Messages indicating success/failure.
    rem         Note that if elevation is done by this script, a new command process window is created: the output of this
    rem         window is not directly accessible to the caller.
    rem
    rem
    setlocal
    set sqlresult=N/A
    if .%1 == . (set /P sqlinstance=Enter SQL instance name, or default to SQLEXPRESS: ) else (set sqlinstance=%1)
    if .%sqlinstance% == . (set sqlinstance=SQLEXPRESS)
    if /I %sqlinstance% == MSSQLSERVER (set sqlservice=MSSQLSERVER) else (set sqlservice=MSSQL$%sqlinstance%)
    if .%2 == . (set sqllogin="%USERDOMAIN%\%USERNAME%") else (set sqllogin=%2)
    rem remove enclosing quotes
    for %%i in (%sqllogin%) do set sqllogin=%%~i
    @echo Adding '%sqllogin%' to the 'sysadmin' role on SQL Server instance '%sqlinstance%'.
    @echo Verify the '%sqlservice%' service exists ...
    set srvstate=0
    for /F "usebackq tokens=1,3" %%i in (`sc query %sqlservice%`) do if .%%i == .STATE set srvstate=%%j
    if .%srvstate% == .0 goto existerror
    rem
    rem elevate if <domain/user> was defaulted
    rem
    if NOT .%2 == . goto continue
    echo new ActiveXObject("Shell.Application").ShellExecute("cmd.exe", "/D /Q /C pushd \""+WScript.Arguments(0)+"\" & \""+WScript.Arguments(1)+"\" %sqlinstance% \""+WScript.Arguments(2)+"\"", "", "runas"); >"%TEMP%\addsysadmin{7FC2CAE2-2E9E-47a0-ADE5-C43582022EA8}.js"
    call "%TEMP%\addsysadmin{7FC2CAE2-2E9E-47a0-ADE5-C43582022EA8}.js" "%cd%" %0 "%sqllogin%"
    del "%TEMP%\addsysadmin{7FC2CAE2-2E9E-47a0-ADE5-C43582022EA8}.js"
    goto :EOF
    :continue
    rem
    rem determine if the SQL service is running
    rem
    set srvstarted=0
    set srvstate=0
    for /F "usebackq tokens=1,3" %%i in (`sc query %sqlservice%`) do if .%%i == .STATE set srvstate=%%j
    if .%srvstate% == .0 goto queryerror
    rem
    rem if required, stop the SQL service
    rem
    if .%srvstate% == .1 goto startm
    set srvstarted=1
    @echo Stop the '%sqlservice%' service ...
    net stop %sqlservice%
    if errorlevel 1 goto stoperror
    :startm
    rem
    rem start the SQL service with the '-m' option (single admin connection) and wait until its STATE is '4' (STARTED)
    rem also use trace flags as follows:
    rem     3659 - log all errors to errorlog
    rem     4010 - enable shared memory only (lpc:)
    rem     4022 - do not start autoprocs
    rem
    @echo Start the '%sqlservice%' service in maintenance mode ...
    sc start %sqlservice% -m -T3659 -T4010 -T4022 >nul
    if errorlevel 1 goto startmerror
    :checkstate1
    set srvstate=0
    for /F "usebackq tokens=1,3" %%i in (`sc query %sqlservice%`) do if .%%i == .STATE set srvstate=%%j
    if .%srvstate% == .0 goto queryerror
    if .%srvstate% == .1 goto startmerror
    if NOT .%srvstate% == .4 goto checkstate1
    rem
    rem add the specified user to the sysadmin role
    rem access tempdb to avoid a misleading shutdown error
    rem
    @echo Add '%sqllogin%' to the 'sysadmin' role ...
    for /F "usebackq tokens=1,3" %%i in (`sqlcmd -S np:\\.\pipe\SQLLocal\%sqlinstance% -E -Q "create table #foo (bar int); declare @rc int; execute @rc = sp_addsrvrolemember '$(sqllogin)', 'sysadmin'; print 'RETURN_CODE : '+CAST(@rc as char)"`) do if .%%i == .RETURN_CODE set sqlresult=%%j
    rem
    rem stop the SQL service
    rem
    @echo Stop the '%sqlservice%' service ...
    net stop %sqlservice%
    if errorlevel 1 goto stoperror
    if .%srvstarted% == .0 goto exit
    rem
    rem start the SQL service for normal connections
    rem
    net start %sqlservice%
    if errorlevel 1 goto starterror
    goto exit
    rem
    rem handle unexpected errors
    rem
    :existerror
    sc query %sqlservice%
    @echo '%sqlservice%' service is invalid
    goto exit
    :queryerror
    @echo 'sc query %sqlservice%' failed
    goto exit
    :stoperror
    @echo 'net stop %sqlservice%' failed
    goto exit
    :startmerror
    @echo 'sc start %sqlservice% -m' failed
    goto exit
    :starterror
    @echo 'net start %sqlservice%' failed
    goto exit
    :exit
    if .%sqlresult% == .0 (@echo '%sqllogin%' was successfully added to the 'sysadmin' role.) else (@echo '%sqllogin%' was NOT added to the 'sysadmin' role: SQL return code is %sqlresult%.)
    endlocal
    pause

    Wednesday, June 5, 2013

    Could not load file or assembly or one of its dependencies. Access is denied

    I was moving an older .Net 2.0 web service to a new IIS box.  I set up everything but each time I loaded the application I got this annoying error!  Cursory search will reveal a miriad of potential issues.

    Here are the usual culprits.
    1. IUSR_USR or impersonated account does not have access to Temporary ASP.NET in Framework.
    2. Account does not have access to the inetpub/wwwroot or wherever the website is hosted.
    3. Checked impersonation.
    This was the issue.  I was using an expired service account which had come over with the web.config file.  Mapped the Authentication > ASP.NET Impersonation to the valid service account and that fixed it!

    Tuesday, June 4, 2013

    URL Encoding Reference

    http://www.w3schools.com/tags/ref_urlencode.asp

    URL Encoding Reference

    ASCII CharacterURL-encoding
    space%20
    !%21
    "%22
    #%23
    $%24
    %%25
    &%26
    '%27
    (%28
    )%29
    *%2A
    +%2B
    ,%2C
    -%2D
    .%2E
    /%2F
    0%30
    1%31
    2%32
    3%33
    4%34
    5%35
    6%36
    7%37
    8%38
    9%39
    :%3A
    ;%3B
    <%3C
    =%3D
    >%3E
    ?%3F
    @%40
    A%41
    B%42
    C%43
    D%44
    E%45
    F%46
    G%47
    H%48
    I%49
    J%4A
    K%4B
    L%4C
    M%4D
    N%4E
    O%4F
    P%50
    Q%51
    R%52
    S%53
    T%54
    U%55
    V%56
    W%57
    X%58
    Y%59
    Z%5A
    [%5B
    \%5C
    ]%5D
    ^%5E
    _%5F
    `%60
    a%61
    b%62
    c%63
    d%64
    e%65
    f%66
    g%67
    h%68
    i%69
    j%6A
    k%6B
    l%6C
    m%6D
    n%6E
    o%6F
    p%70
    q%71
    r%72
    s%73
    t%74
    u%75
    v%76
    w%77
    x%78
    y%79
    z%7A
    {%7B
    |%7C
    }%7D
    ~%7E
    %7F
    `%80
    %81
    %82
    ƒ%83
    %84
    %85
    %86
    %87
    ˆ%88
    %89
    Š%8A
    %8B
    Œ%8C
    %8D
    Ž%8E
    %8F
    %90
    %91
    %92
    %93
    %94
    %95
    %96
    %97
    ˜%98
    %99
    š%9A
    %9B
    œ%9C
    %9D
    ž%9E
    Ÿ%9F
    %A0
    ¡%A1
    ¢%A2
    £%A3
    ¤%A4
    ¥%A5
    ¦%A6
    §%A7
    ¨%A8
    ©%A9
    ª%AA
    «%AB
    ¬%AC
    ­%AD
    ®%AE
    ¯%AF
    °%B0
    ±%B1
    ²%B2
    ³%B3
    ´%B4
    µ%B5
    %B6
    ·%B7
    ¸%B8
    ¹%B9
    º%BA
    »%BB
    ¼%BC
    ½%BD
    ¾%BE
    ¿%BF
    À%C0
    Á%C1
    Â%C2
    Ã%C3
    Ä%C4
    Å%C5
    Æ%C6
    Ç%C7
    È%C8
    É%C9
    Ê%CA
    Ë%CB
    Ì%CC
    Í%CD
    Î%CE
    Ï%CF
    Ð%D0
    Ñ%D1
    Ò%D2
    Ó%D3
    Ô%D4
    Õ%D5
    Ö%D6
    ×%D7
    Ø%D8
    Ù%D9
    Ú%DA
    Û%DB
    Ü%DC
    Ý%DD
    Þ%DE
    ß%DF
    à%E0
    á%E1
    â%E2
    ã%E3
    ä%E4
    å%E5
    æ%E6
    ç%E7
    è%E8
    é%E9
    ê%EA
    ë%EB
    ì%EC
    í%ED
    î%EE
    ï%EF
    ð%F0
    ñ%F1
    ò%F2
    ó%F3
    ô%F4
    õ%F5
    ö%F6
    ÷%F7
    ø%F8
    ù%F9
    ú%FA
    û%FB
    ü%FC
    ý%FD
    þ%FE
    ÿ%FF



    URL Encoding Reference

    The ASCII device control characters -%1f were originally designed to control hardware devices. Control characters have nothing to do inside a URL.
    ASCII CharacterDescriptionURL-encoding
    NULnull character
    SOHstart of header%01
    STXstart of text%02
    ETXend of text%03
    EOTend of transmission%04
    ENQenquiry%05
    ACKacknowledge%06
    BELbell (ring)%07
    BSbackspace%08
    HThorizontal tab%09
    LFline feed%0A
    VTvertical tab%0B
    FFform feed%0C
    CRcarriage return%0D
    SOshift out%0E
    SIshift in%0F
    DLEdata link escape%10
    DC1device control 1%11
    DC2device control 2%12
    DC3device control 3%13
    DC4device control 4%14
    NAKnegative acknowledge%15
    SYNsynchronize%16
    ETBend transmission block%17
    CANcancel%18
    EMend of medium%19
    SUBsubstitute%1A
    ESCescape%1B
    FSfile separator%1C
    GSgroup separator%1D
    RSrecord separator%1E
    USunit separator%1F

    SharePoint Designer CAML - ddwrt:FormatDate with different FormatFlags

    I was asked today again about changing the date formats on a list view.  The user had SP Designer open and I had to wrack my brain on the format codes for straight dates with no time attached. 

    Using the following namespace attribute
    xmlns:ddwrt=http://schemas.microsoft.com/WebParts/v2/DataView/runtime


    Not what we wanted:

    ddwrt:FormatDate(string(@EventDate), 1033, 5) => MM/DD/YYYY HH:MM AM/PM

    What we wanted was:

    ddwrt:FormatDate(string(@EventDate), 1033, 1) => MM/DD/YYYY

    Here is the format chart



    Thanks to http://panvega.wordpress.com/2008/12/08/ddwrtformatdate-with-different-formatflags/

    404 error with WCF querystring using email address in Visual Studio.

    Tyring to build out a RESTful call which would pass an email as an argument.
    I was working in Visual Studio 2010.

    Example:
    http://mysite.com/TheService.svc/Name/bob.smith@white.com/

    Error:
    404 resource not found


    Issue appears to be with the internal web server, "Cassini", in visual studio.
    I deployed this to IIS and the service worked fine.  This is a known bug with Cassini.
    It appears to not be able to handle periods (.=%2E).

    Credit to Stack Overflow.

    http://stackoverflow.com/questions/8491159/email-address-as-part-of-a-wcf-data-service-querystring

    Tuesday, May 28, 2013

    Date Formatting in TSQL

    Trying to find a quick list of format settings for date selections.

    select convert(varchar(10),GetDate(),101) as [MM/DD/YYYY]

    The inline select explanation:

    Arg 1: The datatype you are converting the data type too
    Arg 2: Item being selected which is going to be a datetime object.  Sample uses the GetDate function to make the sample generic.
    Arg 3: The data format you need





    MM/DD/YY USA SELECT CONVERT(VARCHAR(8), GETDATE(), 1) AS [MM/DD/YY] 11/23/98
    MM/DD/YYYY USA SELECT CONVERT(VARCHAR(10), GETDATE(), 101) AS [MM/DD/YYYY] 11/23/1998
    DD.MM.YY German SELECT CONVERT(VARCHAR(8), GETDATE(), 4) AS [DD.MM.YY] 25.12.05
    DD.MM.YYYY German SELECT CONVERT(VARCHAR(10), GETDATE(), 104) AS [DD.MM.YYYY] 25.12.2005

    Thanks to the team at sql server helper.  They have the complete list of Date formats
    http://www.sql-server-helper.com/tips/date-formats.aspx

    Wednesday, May 22, 2013

    Error Sandboxed service is too busy to handle the request

    We have a custom 2010 branding solution in visual studio.  It deploys the Sharepoint branding to each site collection.  Trying to deploy the solution today from the site collection gallery and then from visual studio directly but was getting the dreaded service is busy error.  I have seen this before but was forced to use all three of the presrcibed solutions.  I normally only have had to do either one or two.

    A. Change registry settings

    A known cause is the presence of the following key in the registry of the servers that are running the sandboxed host service. (An additional symptom of this cause is that the service stops a few seconds after starting.)
    HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\RPC
    It does not matter what the value of the key is, or even if the key has any value. If the key is present, the user account in which the sandboxed host process runs must be able to read it because the process tries to when it starts up. By default, the user account does not have permission to read it (because, by default, the key is not present). You must give the Users group of the computer permission to read the key.
    Note: It is not sufficient to give such permission to the Authenticated Users group, because the sandboxed process removes the Authenticated User token from the the user account in which the sandboxed host process runs. This also makes that account a restricted account which means it is not sufficient to give permission to read the key to that account alone. Since the account is not considered authenticated, doing this would have no effect. However, the account does inherit the permissions of the computer’s User group.
    Take the following steps on every server which has the key and which is running the sandboxed host service.
    1. Open the registry editor and navigate to the key.
    2. Right-click the key and select Permissions.
    3. On the dialog that opens, click Add.
    4. In the dialog that opens, enter the following in the Enter the object names to select box: computername\Users.
    5. Click Check Names.
    6. After the name has resolved, click OK.
    7. Restart the sandboxed host service on all servers on which it is to run. It cannot hurt to do an iisreset as well.


    B. Change host file to point clr.microsoft.com to local machine


    You can redirect these attempts by adding the following line to the end of the hosts file located at C:\Windows\System32\drivers\etc:
    127.0.0.1 crl.microsoft.com
    This must be done on all servers running the sandboxed host service. Then restart the SharePoint 2010 User Code Host service on all these servers. It cannot hurt to do an iisreset as well.


    C. Change system configuration files of Sandbox service to skip certificate verification in Code Access Security policies.

    1. Open SharePoint 2010 Central Administration
    2. Navigate to “Configure service accounts” in Security section
    3. Select ‘Windows Service – Microsoft SharePoint Foundation Sandboxed Code Service’ in the dropdown control.
    4. Then you will see which account is used for Sandbox Service.
      (Get-SPManagedAccount –Identity "DOMAINUserCodeServiceAccont").Sid.Value
    Now, it is time to check and update registry settings for WinTrust.
    1. Open the registry editor and navigate to:
      HKEY_USERS{SID you obtained earlier}SOFTWARE/Microsoft/Windows/CurrentVersion/WinTrust/Trust Providers/Software Publishing
    2. Change value of “State” key to 0x00023e00.
    3. Restart Sandbox Service
    4. Perform IIS reset 




    Thanks to the pdf sharepoint team  

    http://www.pdfshareforms.com/error-sandboxed-too-busy-handle-request/

     and

    Rick Kirkham from the Sharepoint dev team
    http://blogs.msdn.com/b/sharepointdev/archive/2011/02/08/error-the-sandboxed-code-execution-request-was-refused-because-the-sandboxed-code-host-service-was-too-busy-to-handle-the-request.aspx

    Wednesday, May 15, 2013

    Move Inetpub to another Drive


    Needed to move inetpub to the d drive

    MOVEIISROOT.BAT D

    http://blogs.iis.net/thomad/archive/2008/02/10/moving-the-iis7-inetpub-directory-to-a-different-drive.aspx

    The MOVEIISROOT.BAT Script:

    REM PLEASE BE AWARE: SERVICING (I.E. HOTFIXES AND SERVICE PACKS) WILL STILL REPLACE FILES
    REM IN THE ORIGINAL DIRECTORIES. THE LIKELIHOOD THAT FILES IN THE INETPUB DIRECTORIES HAVE
    REM TO BE REPLACED BY SERVICING IS LOW BUT FOR THIS REASON DELETING THE ORIGINAL DIRECTORIES
    REM IS NOT POSSIBLE.
    @echo off
    IF "%1" == "" goto err
    setlocal
    set MOVETO=%1:\
    REM simple error handling if drive does not exist or argument is wrong
    IF NOT EXIST %MOVETO% goto err
    REM Backup IIS config before we start changing config to point to the new path
    %windir%\system32\inetsrv\appcmd add backup beforeRootMove

    REM Stop all IIS services
    iisreset /stop
    REM Copy all content
    REM /O - copy ACLs
    REM /E - copy sub directories including empty ones
    REM /I - assume destination is a directory
    REM /Q - quiet
    REM echo on, because user will be prompted if content already exists.
    echo on
    xcopy %systemdrive%\inetpub %MOVETO%inetpub /O /E /I /Q
    @echo off
    REM Move AppPool isolation directory
    reg add HKLM\System\CurrentControlSet\Services\WAS\Parameters /v ConfigIsolationPath /t REG_SZ /d %MOVETO%inetpub\temp\appPools /f
    REM Move logfile directories
    %windir%\system32\inetsrv\appcmd set config -section:system.applicationHost/sites -siteDefaults.traceFailedRequestsLogging.directory:"%MOVETO%inetpub\logs\FailedReqLogFiles"
    %windir%\system32\inetsrv\appcmd set config -section:system.applicationHost/sites -siteDefaults.logfile.directory:"%MOVETO%inetpub\logs\logfiles"
    %windir%\system32\inetsrv\appcmd set config -section:system.applicationHost/log -centralBinaryLogFile.directory:"%MOVETO%inetpub\logs\logfiles"
    %windir%\system32\inetsrv\appcmd set config -section:system.applicationHost/log -centralW3CLogFile.directory:"%MOVETO%inetpub\logs\logfiles"
    REM Move config history location, temporary files, the path for the Default Web Site and the custom error locations
    %windir%\system32\inetsrv\appcmd set config -section:system.applicationhost/configHistory -path:%MOVETO%inetpub\history
    %windir%\system32\inetsrv\appcmd set config -section:system.webServer/asp -cache.disktemplateCacheDirectory:"%MOVETO%inetpub\temp\ASP Compiled Templates"
    %windir%\system32\inetsrv\appcmd set config -section:system.webServer/httpCompression -directory:"%MOVETO%inetpub\temp\IIS Temporary Compressed Files"
    %windir%\system32\inetsrv\appcmd set vdir "Default Web Site/" -physicalPath:%MOVETO%inetpub\wwwroot
    %windir%\system32\inetsrv\appcmd set config -section:httpErrors /[statusCode='401'].prefixLanguageFilePath:%MOVETO%inetpub\custerr
    %windir%\system32\inetsrv\appcmd set config -section:httpErrors /[statusCode='403'].prefixLanguageFilePath:%MOVETO%inetpub\custerr
    %windir%\system32\inetsrv\appcmd set config -section:httpErrors /[statusCode='404'].prefixLanguageFilePath:%MOVETO%inetpub\custerr
    %windir%\system32\inetsrv\appcmd set config -section:httpErrors /[statusCode='405'].prefixLanguageFilePath:%MOVETO%inetpub\custerr
    %windir%\system32\inetsrv\appcmd set config -section:httpErrors /[statusCode='406'].prefixLanguageFilePath:%MOVETO%inetpub\custerr
    %windir%\system32\inetsrv\appcmd set config -section:httpErrors /[statusCode='412'].prefixLanguageFilePath:%MOVETO%inetpub\custerr
    %windir%\system32\inetsrv\appcmd set config -section:httpErrors /[statusCode='500'].prefixLanguageFilePath:%MOVETO%inetpub\custerr
    %windir%\system32\inetsrv\appcmd set config -section:httpErrors /[statusCode='501'].prefixLanguageFilePath:%MOVETO%inetpub\custerr
    %windir%\system32\inetsrv\appcmd set config -section:httpErrors /[statusCode='502'].prefixLanguageFilePath:%MOVETO%inetpub\custerr
    REM Make sure Service Pack and Hotfix Installers know where the IIS root directories are
    reg add HKLM\Software\Microsoft\inetstp /v PathWWWRoot /t REG_SZ /d %MOVETO%inetpub\wwwroot /f
    reg add HKLM\Software\Microsoft\inetstp /v PathFTPRoot /t REG_SZ /d %MOVETO%inetpub\ftproot /f
    REM Do the same for x64 directories
    if not "%ProgramFiles(x86)%" == "" reg add HKLM\Software\Wow6432Node\Microsoft\inetstp /v PathWWWRoot /t REG_EXPAND_SZ /d %MOVETO%inetpub\wwwroot /f
    if not "%ProgramFiles(x86)%" == "" reg add HKLM\Software\Wow6432Node\Microsoft\inetstp /v PathFTPRoot /t REG_EXPAND_SZ /d %MOVETO%inetpub\ftproot /f
    REM Restart all IIS services
    iisreset /start
    echo.
    echo.
    echo ===============================================================================
    echo Moved IIS7 root directory from %systemdrive%\ to %MOVETO%.
    echo.
    echo Please verify if the move worked. If so you can delete the %systemdrive%\inetpub directory.
    echo If something went wrong you can restore the old settings via
    echo     "APPCMD restore backup beforeRootMove"
    echo and
    echo     "REG delete HKLM\System\CurrentControlSet\Services\WAS\Parameters\ConfigIsolationPath"
    echo You also have to reset the PathWWWRoot and PathFTPRoot registry values
    echo in HKEY_LOCAL_MACHINE\Software\Microsoft\InetStp.
    echo ===============================================================================
    echo.
    echo.
    endlocal
    goto success
    REM error message if no argument or drive does not exist
    :err
    echo.
    echo New root drive letter required.
    echo Here an example how to move the IIS root to the F:\ drive:
    echo.
    echo MOVEIISROOT.BAT F
    echo.
    echo.
    :success