Archive for category SharePoint
SharePoint Central Admin error – “The specified user or domain group was not found”
Posted by Jake in SharePoint on April 7, 2011
While working with SharePoint Central Admin, I tried to access the Service Applications page (“Manage Service Applications” from Application Management). Before getting to the page, I received the error “The specified user or domain group was not found.” I checked the SharePoint logs and found this exception:
“SPAce PrincipalName domain\test.user cannot be resolved. This ACE will not be effective. System.Security.Principal.IdentityNotMappedException: Some or all identity references could not be translated.”
(For blogging, purposes, I am using the name “domain\test.user”) The Principal Name, “domain\test.user” happened to be an actual user that was no longer at the company. It appeared that this user, was being used for one of the service application administrators. I checked with Operations and indeed, “test.user” was purged from Exchange the day before. Working with operations, we recreated the same user name. We were unsure that this would work since the unique identifier of that user would be different, but it was worth a shot. After that user was added, I was able to access the Service Applications page again. Success!
The next step was to remove the user as an admin from the service application. For this situation, the User Profile service application was the problem. I accessed the Administrators dialog and removed the user from the list of admins.
The same user was also listed in the “Connections Permissions for User Profile Service Application.” I removed the user from that list as well.
With the user removed from the service application, Operations purged that user again. Afterward, I was able to access the Service Applications page without the error.
Powershell script for updating a publishing page Page Layout in a site collection
Posted by Jake in SharePoint on April 6, 2011
One of the page layout templates was changed in a SharePoint 2010 site collection that I was working on. There were already over 300 pages that were creating using the old Page Layout. Enter… Powershell! It took about two hours to write this script (with help from The Google) but it will probably save a day of work updating all those pages individually through the UI.
The script takes three parameters, the old or current page layout name, the new page layout name and an optional –all parameter which will traverse all the sites of a site collection. Enjoy.
# Description: # Update the layout page for all matching pages of the current page layout # Checkout, Change layout, Check-in pages in a site collection # # Syntax: # ./UpdateLayoutPages [-PageLayoutCurrent] [-PageLayoutNew] [-all] # # Parameters: # -PageLayoutCurrent - The page layout that is currently in use and will be updated # -PageLayoutNew - The new page layout that pages will be updated to # -all - Update subsites in the site collection # # Modifications: # v1.0 - April 5th, 2011 # Initial version # # Settings set-variable -option constant -name url -value http://localhost # Site collection set-variable -option constant -name comment -value "Batch PageLayout Update" # Publishing comment # Function: Update-SPPagesPageLayout # Description: Update a single page in a Publishing Web # Parameters: publishingPage, pageLayout, comment function Update-SPPagesPageLayout ([Microsoft.SharePoint.Publishing.PublishingPage]$publishingPage, [Microsoft.SharePoint.Publishing.PageLayout] $pageLayoutNew, [string]$comment) { Write-Host "Updating the page:" $publishingPage.Name "to Page Layout:" $pageLayoutNew.Title $publishingPage.CheckOut(); $publishingPage.Layout = $pageLayoutNew; $publishingPage.ListItem.Update(); $publishingPage.Update() $publishingPage.CheckIn($comment); if ($publishingPage.ListItem.ParentList.EnableModeration) { $publishingPage.ListItem.File.Approve("Publishing Page Layout correction"); } } # Function: Update-AllSPPagesPageLayouts # Description: Loop through all the pages in a Publishing Web and update their page layout # Parameters: web, pageLayoutCurrent, pageLayoutNew, comment # comment Comment to accompany the checkin Function Update-AllSPPagesPageLayouts ([Microsoft.SharePoint.SPWeb]$web, [Microsoft.SharePoint.Publishing.PageLayout]$pageLayoutCurrent, [Microsoft.SharePoint.Publishing.PageLayout]$pageLayoutNew, [string]$comment) { #Check if this is a publishing web if ([Microsoft.SharePoint.Publishing.PublishingWeb]::IsPublishingWeb($web) -eq $true) { $pubweb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web); $pubcollection=$pubweb.GetPublishingPages() #Go through all pages checking for pages with the "current" page layout for($i=0; $i -lt $pubcollection.count; $i++) { if($pubcollection[$i].Layout.Title -eq $pageLayoutCurrent.Title) { Update-SPPagesPageLayout $pubcollection[$i] $pageLayoutNew $comment } } } $web.Close(); } # Check Parameters if(($args[0] -ne $null) -and ($args[1] -ne $null)) { Write-Host "** Update Layout Pages from-" $args[0] "-to-" $args[1] "-on URL" $url $pageLayoutNameCurrent = $args[0]; $pageLayoutNameNew = $args[1]; $site = new-object Microsoft.SharePoint.Publishing.PublishingSite($url) Write-Host "Checking if both page layouts exist in the site..." # Check if the current pagelayout exists in this site collection $pageLayouts = $site.GetPageLayouts($true); $pageLayouts | ForEach-Object { if ($_.Title -eq $pageLayoutNameCurrent) { Write-Host "Found CURRENT page layout: " $pageLayoutNameCurrent $pageLayoutCurrent = $_; } } # Check if the new pagelayout exists in this site collection $pageLayouts | ForEach-Object { if ($_.Title -eq $pageLayoutNameNew) { Write-Host "Found NEW page layout: " $pageLayoutNameNew $pageLayoutNew = $_; } } # Do not continue if the either pageLayout does not exist if(($pageLayoutCurrent -ne $null) -and ($pageLayoutNew -ne $null)) { # Update all subsites if($args[2] -eq "-all") { $site.Site.allwebs | foreach { Write-Host "Checking Web: " $_.Title Update-AllSPPagesPageLayouts $_ $pageLayoutCurrent $pageLayoutNew $comment } } else { $site.rootweb | foreach { Write-Host "Checking Web: " $_.Title Update-AllSPPagesPageLayouts $_ $pageLayoutCurrent $pageLayoutNew $comment } } } Write-Host "**Done" } else { Write-Host "Missing arguments. Please check your parameters" } #End
Error occurred in deployment step ‘Recycle IIS Application Pool’: The local SharePoint server is not available. Check that the server is running and connected to the SharePoint farm.
Posted by Jake in SharePoint, Visual Studio on November 4, 2010
If you get this error when deploying a SharePoint solution in Visual Studio on a SharePoint server, check that you have db_owner SQL Server permissions on the SharePoint content databases.
Update: I received a similar error to the one listed above:
Error occurred in deployment step ‘Recycle IIS Application Pool’:<nativehr>0x80070005</nativehr><nativestack></nativestack> Access denied.
For this error, make sure that you are a Site Collection Administrator
Displaying a SharePoint Modal Dialog window from SPGridView
Posted by Jake in .Net, JavaScript, SharePoint on November 4, 2010
I recently built a web part that required a list of announcements with summaries to be presented to a group of users. Additionally, there was detailed content that was to be displayed in a Pop-up type window. I used a gridview to display the list, which was pulled in from a web service and passing in a datatable. That part was rather easy, but the data for the details was stored in a column that contained HTML formed text. My first thought was to pass that to a javascript function that would call the method for displaying a SharePoint dialog: SP.UI.ModalDialog.showModalDialog();
When I added the HTML as a parameter to the javascript function, the result of doing that was rather odd. The HTML text was displayed in the web part itself, which was not going to work. I tried a few workarounds like encoding the HTML text and such, but I did not get good results with that either. Instead, I knew that I had the ID for the items that I was displaying in the list. I could pass in the ID to the dialog page and retrieve the HTML text at that point. Unfortunately, it required two round trips to the web service (and subsequently the SQL Server).
Another issue when displaying the dialog was that the page that I was displaying contained all the elements of the master page that typical pages display (header, footer, etc). This made the dialog too busy for the simple task it was asked to do. To fix this, I added the MasterPageFile attribute to the Page directive which overrides DynamicMasterPageFile attribute.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AnnouncementPage.aspx.cs" Inherits="MyPages.WebParts.Layouts.AnnouncementPage" DynamicMasterPageFile="~masterurl/custom.master" MasterPageFile="~/_layouts/applicationv4.master" %>
In the end, a uncluttered summary list and detailed model dialog:
Code that made it happen:
<script type="text/javascript"> function OpenDialog(aid) { var options = SP.UI.$create_DialogOptions(); options.url = "/_layouts/MyPages/AnnouncementPage.aspx?announcementId=" + aid; options.width = 560; options.height = 480; options.dialogReturnValueCallback = Function.createDelegate(null, OnCloseDialog); SP.UI.ModalDialog.showModalDialog(options); } </script> <div class="spgridannounce"> <SharePoint:SPGridView ID="spGridViewAnnouncements" runat="server" AutoGenerateColumns="false" ShowHeader="false"> <HeaderStyle BackColor="Transparent" ForeColor="#08630C" /> <AlternatingRowStyle BackColor="Transparent" /> <RowStyle BackColor="Transparent" ForeColor="#BF5629" /> <Columns> <asp:TemplateField> <HeaderTemplate> Announcement</HeaderTemplate> <HeaderStyle /> <ItemTemplate> <a href='javascript:OpenDialog(<%# Eval("announcement_id")%>)'> <%# Eval("subject") %> </a> </ItemTemplate> </asp:TemplateField> </Columns> </SharePoint:SPGridView> </div>
Your client does not support opening this list with Windows Explorer
Posted by Jake in SharePoint on October 13, 2010
You are happy working in SharePoint, creating document libraries and new pages with riveting content, when you decide you’d like to open up a library in Explorer view and blamo!
There are various theories on this problem, but for me, the solution was to activate the “Desktop Experience” feature from Server Manager. My development environment is on Windows Server 2008 Standard and SharePoint 2010.
Open Server Manager, Add a Feature:
Select Desktop Experience:
Reboot the server and you should be able to open from the File Explorer until the cows come home:
Display SharePoint list items based on date range
Posted by Jake in SharePoint on September 17, 2010
There was a request to display items (“How-To Tips”) based on a date range. Seemed like a reasonable request, but I didn’t see anything out of the box that provided this functionality. To get this done, the obvious choice was to use the Content Query Web Part (CQWP) and create a custom list that contained the tip items. In the custom list, I created the columns: Tip Description, Tip URL (in case a tip linked to another page/site), Display Start Date and Display End Date and Background Image (the requester also wanted a pretty image for the background of this web part).
Now that I had those columns to work with, I added a CQWP to the page and edited the web part to use my custom list:
To get the date range functionality, I used the Additional Filters section and my Date columns to filter on items with a Display Start Date less than or equal to [Today] and a Display End Date greater than or equal to [Today].
All that is left to do is add items to the list that have the correct start and end dates and the tip(s) appear on the web part:
There is more to do with getting the background image. I will blog that someday.
KeywordQuery Error: Property doesn’t exist or is used in a manner inconsistent with schema setting
Posted by Jake in SharePoint on September 9, 2010
In the following code of a web part that was doing a custom KeywordQuery search, I received the error “Property doesn’t exist or is used in a manner inconsistent with schema settings.” The Properties that I was adding to the KeywordQuery had not yet been mapped in the Search Service Application, Metadata Properties:
//Get associated search service application SearchServiceApplicationProxy proxy = (SearchServiceApplicationProxy)SearchServiceApplicationProxy.GetProxy (SPServiceContext.GetContext(SPContext.Current.Site)); //Use Keyword Query Microsoft.Office.Server.Search.Query.KeywordQuery keywordQuery = new Microsoft.Office.Server.Search.Query.KeywordQuery(proxy); keywordQuery.ResultsProvider = Microsoft.Office.Server.Search.Query.SearchProvider.Default; //Return following properties keywordQuery.SelectProperties.Add("ProjectCreator"); keywordQuery.SelectProperties.Add("ProjectName"); keywordQuery.SelectProperties.Add("ProjectDescription"); keywordQuery.SelectProperties.Add("ProjectStage"); keywordQuery.SelectProperties.Add("Path"); keywordQuery.SelectProperties.Add("Title"); keywordQuery.SelectProperties.Add("Id"); keywordQuery.SelectProperties.Add("SiteName");
To map these properties, go to the Search Service Application –> Metadata Properties page in Central Administration –> Application Management.
Select “New Managed Property”
Type the new Managed Property and add a mapping
In my case, I am mapping to properties that were promoted from an InfoPath form.
Once the property is mapped, re-run an incremental or full crawl on your content source which contains the property
Error occurred in deployment step Add Solution: Value does not fall within the expected range
Posted by Jake in SharePoint on August 9, 2010
A SharePoint 2010 solution I was working on contained several different types projects (MasterPage, ContentTypes, EventReceivers). At one point, I started getting this error: “Error occurred in deployment step Add Solution: Value does not fall within the expected range.”
By unloading projects I narrowed it down to my ContentType feature. The ID of the content type had a typo (I left a closed brace sign at the end of the ID). While googling for this error, there wasn’t an exact match for my typo, rather it was the method to isolate the problem, which is to unload projects and features until I found the culprit.
<ContentType ID="0x010100C568DB52D9D0A14D9B2FDCC96666E9F2006748130EC3DB064584E219954237AF3900F7AEFF
AB848C45AE85AC577F52131053}"
Name="Three Columns Main"
Group="My Pages"
Description="Main Page with three columns"
Version="0"
Inherits="TRUE"
Overwrite="TRUE">
<FieldRefs>
<FieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Name="Title" Required="TRUE" />
<FieldRef ID="{888D470D-BF80-4DF2-A2D6-72EBDFF90DE1}" Name="PortalHeaderText" />
</FieldRefs>
</ContentType>
SharePoint Ribbon customization for a specific content type
Posted by Jake in SharePoint on June 17, 2010
I wanted to utilize the new SharePoint 2010 Ribbon for performing a custom action on items in a custom list. The list contained items that were of a custom content type (lots of custom work going on). With some great posts from Chris O’Brien and MSDN, I found all the XML needed to accomplish the task. I also took advantage of the Custom Tab, Button Groups and Notifications while I was at it.
A couple of things to note when targeting the content type for ribbon customization. The content type that was used for the CustomAction was created through code, so I didn’t have the ID at design time to add to the Ribbon customization. I deployed the content type first, looked up the content type ID (this can be done quickly by viewing the properties of the CT and looking at the ID in the URL). Once I had that ID, I was able to set the CustomAction RegistrationId to the ID and the RegriatrationType to “ContentType.” Also, I only wanted the button to be active when one or more items were selected. I modified the EnabledScript function to make that happen.
<?xml version="1.0" encoding="utf-8"?> <Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <CustomAction Id="SharePoint.Ribbon.SohemasTab" Location="CommandUI.Ribbon" RegistrationId="0x0100ECB394A7B088A843A2421FB7663F957602" RegistrationType="ContentType" > <CommandUIExtension> <CommandUIDefinitions> <CommandUIDefinition Location="Ribbon.Tabs._children"> <Tab Id="SharePoint.Ribbon.SohemasTab" Title="Sohema Commands" Description="Sohema Workflow Commands" Sequence="501"> <Scaling Id="SharePoint.Ribbon.SohemasTab.Scaling"> <MaxSize Id="SharePoint.Ribbon.SohemasTab.SohemaActionGroup.MaxSize" GroupId="SharePoint.Ribbon.SohemasTab.SohemaActionGroup" Size="OneLarge"/> <Scale Id="SharePoint.Ribbon.SohemasTab.SohemaActionGroup.Scaling.SohemasTabScaling" GroupId="SharePoint.Ribbon.SohemasTab.SohemaActionGroup" Size="OneLarge" /> </Scaling> <Groups Id="SharePoint.Ribbon.SohemasTab.Groups"> <Group Id="SharePoint.Ribbon.SohemasTab.SohemaActionGroup" Description="Contains Sohema Action items" Title="Perform Sohema Actions" Sequence="52" Template="Ribbon.Templates.OneLargeExample"> <Controls Id="SharePoint.Ribbon.SohemasTab.SohemaActionGroup.Controls"> <Button Id="Ribbon.Documents.New.SohemaPushToCSVRibbonButton" Alt="Push selected item(s) to CSV" Sequence="95" LabelText="Push Sohema(s) To CSV" Image16by16="/_layouts/images/SubcontractorSohema/ToCSV16x16.png" Image32by32="/_layouts/images/SubcontractorSohema/ToCSV32x32.png" Command="Command.SohemaPushButton" TemplateAlias="PushSohema" /> </Controls> </Group> </Groups> </Tab> </CommandUIDefinition> <CommandUIDefinition Location="Ribbon.Templates._children"> <GroupTemplate Id="Ribbon.Templates.OneLargeExample"> <Layout Title="OneLarge" LayoutTitle="OneLarge"> <Section Alignment="Top" Type="OneRow"> <Row> <ControlRef DisplayMode="Large" TemplateAlias="PushSohema" /> </Row> </Section> </Layout> </GroupTemplate> </CommandUIDefinition> </CommandUIDefinitions> <CommandUIHandlers> <CommandUIHandler Command="Command.SohemaPushButton" CommandAction="javascript: var notificationId = SP.UI.Notify.addNotification('Processing Sohemas');" EnabledScript="javascript:function moreThanOneEnabled() { var items = SP.ListOperation.Selection.getSelectedItems(); var ci = CountDictionary(items); return (ci > 0); } moreThanOneEnabled(); " /> </CommandUIHandlers> </CommandUIExtension> </CustomAction> </Elements>
Adding a CSS file to a SharePoint 2010 Application page in VS 2010
Posted by Jake in SharePoint, Visual Studio on June 1, 2010
A quick run down on the steps to add a Cascading StyleSheet to a SharePoint Application page in Visual Studio 2010
From the Visual Studio 2010 Solution Explorer, select the project, right click and select the Add option and then the “SharePoint Mapped Folder…”
The “Add SharePoint Mapped Folder” dialog is presented which displays all the folders under {SharePointRoot}:
Select the location that you would like to place your Stylesheet, which in most cases will be: {ProgramFiles}\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\1033\STYLES
Once the STYLES folder is added, it may be easier to add a custom folder that will contain your CSS file(s)
Now that the folder structure is complete, you can add a stylesheet to that folder:
Inside your application page, reference the stylesheet within the PlaceHolderAdditionalPageHead ContentPlaceHolder similar to: <link type="text/css" rel="stylesheet" href="/_layouts/1033/styles/Sohema/sohema.css" />
The details of adding the files to the package is nicely handled by Visual Studio and included in the Package xml files:
Deploy your solution and notice the addition of your CSS file under the location that was specified:
Add content to your CSS file and you’re done!
You must be logged in to post a comment.