SharePoint 2013 released…


Yes!! the SharePoint 2013 Foundation (RTM) can be downloaded from http://www.microsoft.com/nl-be/download/details.aspx?id=35488

if you look at the size of the file: 820Mb!! the previous version was “only” 180Mb, seems that there is something new in this version 😉 😉

download  SharePoint 2013 server at technet: http://technet.microsoft.com/en-us/evalcenter/hh973397.aspx

Posted in Sharepoint | Leave a comment

SharePoint 2010 hotfix installation problems


We patched yesterday a SharePoint Server farm (2 SP servers) with three cumulative updates (Aug, Oct, Dec 2011) and faced the following errors:

  • Failed to install the application content files
    • Additional Extra info:
      • Object reference not set to an instance of an object
    • StackTrace:
      • at Microsoft.SharePoint.Administration.SPAspConfigurationFile.ApplyActionToXmlDocument
      • at Microsoft.SharePoint.Administration.SPAspConfigurationFile.MergeWebConfig
      • at Microsoft.SharePoint.Administration.SPWebService.ApplyApplicationContentToLocalServer
      • at Microsoft.SharePoint.PostSetupConfiguration.ApplicationContentTask.Run
    • Cause:
      • We encountered an orphaned config file in the <14-hive>/config folder.
    • Solution:
      • just moved the file to a backup location and the problem was solved
  • “Failed to upgrade SharePoint Products”
  • “Upgrade Timer job is exiting due to exception”
    • Additional Extra Info:
      • Microsoft.SharePoint.Upgrade.SPUpgradeException: Upgrade completed with errors
    • Cause
      • An extra created log-error file was created with additional information concerning the upgrade. we had 2 extra problems in the SP configuration
        • [Found a missing feature Id]
        • File [Features\featurename\webpartX.webpart] is referenced [1] times in the database [WSS_Content], but is not installed on the current farm
    • Solution
      • Foud a missing feature Id
        • Go to the Content DB and use the follow sql statement to obtain the SiteUrl of the site where the missing feature is located
          • SELECT f.FeatureId, Title, FullUrl
            FROM Features f
            INNER JOIN Webs w ON f.WebId = w.Id
            WHERE FeatureId = ‘<featureId>’
        • use this tool to remove missing features: http://archive.msdn.microsoft.com/WssRemoveFeatureFrom
      • File XX is referenced [1] times in the database [WSS_Content]
        • Go to the Content DB and use the follow sql statement to find back the location of the missing file(s)
          • SELECT FROM AllDocs WHERE SetupPath like ‘%<missingfilename>%’
        • Delete the file from that location via the interface
        • Clear the recycle bin (or at least that deleted file ;-))

After installing a hotfix, it (could) be helpfull to restart the server before executing the PSConfig wizard.

Posted in Sharepoint | Tagged , , , | 1 Comment

SharePoint: The user does not exist or is not unique (FBA)


We faced this error during the last days and couldn’t find (quickly) a solution for it. The solution in our case was very simple and stupid 🙂

Most of the time, getting this errors will result in a long search on the internet finding out that you are not the only one with that error message (sometimes it is the case :-)) The message itself is very general and can occor in lots of different configurations (so not only SharePoint). I will first elaborate on our configuration and the things we checked and then finally mention the cause of our problem…

The error occured on the moment we wanted that add a new extranet user (FBA-user) to SharePoint via the SPWeb.EnsureUser() method. Adding Active Directory-accounts was not a problem! And last but not least, the code worked in the past and on the same systems!

Our setup and configuration:

  • a SharePoint 2010 Server intranet + extended extranet.
  • all web.config’s were nicely checked (3 in total: Intranet, Extranet, SecurityToken)
    • a custom MembershipProvider was created en in-place(partially re-use of code from other projects).
    • We checked that the name of that provider was not misspelled in all config files and code blocks)
  • the superuseraccount and superreaderacount was defined (keeping in mind that you use the claims-prefix (“i:0#.w|domain\account”)
    • this setting is actually not required for the actually solution. We have an environment without these settings and everything was working well…

 

Cause:

  • When using the SPWeb.EnsureUser() method, SharePoint is loading your Membershipprovider assembly and executes the GetUser() methods. Since the user was not present in our internal user database, SharePoint throwed that exception.
  • But why did it worked in the past? => the responsible code of creating the records in the DB was moved by mistake and put after the SPWeb.EnsureUser() statement.

Afterwards it’s easy to say: look at the message! “I cannot  find a user!” but in a lot of case error messages are not always straight-forward and the cause is often something else…but not in this case 🙂 …so exceptions on exceptions do occur.

Posted in Sharepoint | Tagged , | Leave a comment

SharePoint 2010 – Troubleshooting Access Denied


We had a mind-breaking issue on our demo environment today. In the matter of security, a site collection administrator is always capable of browsing through the intranet. But security tests with “normal” users didn’t succeeded (Permission Level: Contribute), we’ll received always an “Access Denied”:

We followed these steps to identify the problem:

  1. Checking al common libraries (Master Pages, Style Library, Site Collection Images) on the following topics:
    1. All files checked-in (MasterPage, PageLayout, Stylesheets, Scripts, Images …)
    2. All files are published
    3. Version is higher or equal than “1.0”
    4. The security group or the user can at least read the library (Check Permissions for users…)
  2. Our Homepage and MasterPage contains custom webparts
    1. one by one, remove everything in your MasterPage
      the layout became so basic but at a suddent moment, the “Access Denied” was vanished 🙂

the actual cause:

one custom webpart had a routing for checking if a user is member of a certain SharePoint group, changing this piece into SPRunWithElevatedPrivileges did the trick 🙂 A normal user with Contribute rights has no rights to check for security settings…

It is a pitty that the logging of SharePoint is not smarter enough to elaborate more information when an Access Denied exception is thrown. Hopefully this is getting better in the next release 🙂

Posted in Geen categorie | Leave a comment

SharePoint 2010 Powershell – Detailed Site Overview


It’s not the first time that one of our customers ask us for a complete overview of there intranet. The Content & Structure page is nice and easy but cumbersome while navigation.

I wrote a powershell script to accomplish this. It was time consuming but not that difficult, just enumerating all webs, lists, permissions, fields, views…

the output of the script gives you 2 xml files:

File 1: the execution time of the script is combined with the filename (for historical purposes)

File 2: just a normal fixed filename, very handy for reporting!

The actual powershell script:


# Powershell: Generated Site Overview.
#
# Copyright (c) 2011 Aurelium
# Dual licensed under the MIT and GPL licenses:
# http://www.opensource.org/licenses/mit-license.php
# http://www.gnu.org/licenses/gpl.html
# @author: Steven Derveaux (http://www.aurelium.be)
# @version: 1.0 - 2012/05/23

param([string]$url = “xml”, [switch]$help)

function GetHelp() {
$HelpText = @”

DESCRIPTION:
NAME: SP-GetSiteStructureList
Enumerates through a Site Collection in the farm and lists all libraries to a csv file

SYNTAX:

SP-GetSiteStructureList -url http://yoursite

“@
$HelpText

}

function EnumSiteStructure($url){
[xml]$xml = “”
$date = Get-Date

$site = new-object Microsoft.SharePoint.SPSite ($url)
$web = $site.OpenWeb()
$filename = “Structure_” + $web.Url.Replace(“http://&#8221;,””).Replace(“/”,”_”) + “.xml”;
$filename2 = “Structure_” + $web.Url.Replace(“http://&#8221;,””).Replace(“/”,”_”) + “_” + $date.ToString(“yyyyMMdd_hhmmss”) + “.xml”;

$attr = $xml.CreateAttribute(“ScriptRun”)

$attr.Value = $date.ToString(“dd/MM/yyyy hh:mm:ss”)
[Void]$xml[“Websites”].SetAttributeNode($attr)

foreach ($web in $site.AllWebs){

$xmlWeb = $xml.CreateElement(“Website”)

$attr = $xml.CreateAttribute(“Title”)
$attr.Value = $web.Title
[void]$xmlWeb.SetAttributeNode($attr)

$attr = $xml.CreateAttribute(“Url”)
$attr.Value = $web.Url
[void]$xmlWeb.SetAttributeNode($attr)

$attr = $xml.CreateAttribute(“HasUniqueRoleAssignments”)
$attr.Value = $web.HasUniqueRoleAssignments
[Void]$xmlWeb.SetAttributeNode($attr)

$attr = $xml.CreateAttribute(“Created”)
$attr.Value = $web.Created
[Void]$xmlWeb.SetAttributeNode($attr)

$xmlRoleAssignments = $xml.CreateElement(“RoleAssignments”)

foreach ($roleAssignment in $Web.RoleAssignments){
$xmlRoleAssignment = $xml.CreateElement(“RoleAssignment”)
$attr = $xml.CreateAttribute(“Member”)
$attr.Value = $roleAssignment.Member
[Void]$xmlRoleAssignment.SetAttributeNode($attr)

foreach($roleBinding in $roleAssignment.RoleDefinitionBindings){
if ($roleBinding.Name -ne “Limited Access”){
$xmlRoleBinding = $xml.CreateElement(“RoleBinding”)

$attr = $xml.CreateAttribute(“Name”)
$attr.Value = $roleBinding.Name
[Void]$xmlRoleBinding.SetAttributeNode($attr)
[Void]$xmlRoleAssignment.AppendChild($xmlRoleBinding)
}
}
[Void]$xmlRoleAssignments.AppendChild($xmlRoleAssignment)
}

[Void]$xmlWeb.AppendChild($xmlRoleAssignments)

$xmlLists = $xml.CreateElement(“Lists”)

foreach ($list in $web.Lists){
if ($list.Hidden -eq 0){

$xmlList = $xml.CreateElement(“List”)
$attr = $xml.CreateAttribute(“Title”)
$attr.Value = $list.Title
[Void]$xmlList.SetAttributeNode($attr)

$attr = $xml.CreateAttribute(“BaseType”)
$attr.Value = $list.BaseType
[Void]$xmlList.SetAttributeNode($attr)

$attr = $xml.CreateAttribute(“ContentTypesEnabled”)
$attr.Value = $list.ContentTypesEnabled
[Void]$xmlList.SetAttributeNode($attr)

$attr = $xml.CreateAttribute(“OnQuickLaunch”)
$attr.Value = $list.OnQuickLaunch
[Void]$xmlList.SetAttributeNode($attr)

$attr = $xml.CreateAttribute(“HasUniqueRoleAssignments”)
$attr.Value = $list.HasUniqueRoleAssignments
[Void]$xmlList.SetAttributeNode($attr)

$attr = $xml.CreateAttribute(“EnableVersioning”)
$attr.Value = $list.EnableVersioning
[Void]$xmlList.SetAttributeNode($attr)

$attr = $xml.CreateAttribute(“EnableMinorVersions”)
$attr.Value = $list.EnableMinorVersions
[Void]$xmlList.SetAttributeNode($attr)

$attr = $xml.CreateAttribute(“EnableModerations”)
$attr.Value = $list.EnableModerations
[Void]$xmlList.SetAttributeNode($attr)

$attr = $xml.CreateAttribute(“ID”)
$attr.Value = $list.ID
[Void]$xmlList.SetAttributeNode($attr)

$attr = $xml.CreateAttribute(“ItemCount”)
$attr.Value = $list.Items.Count
[Void]$xmlList.SetAttributeNode($attr)

$xmlRoleAssignments = $xml.CreateElement(“RoleAssignments”)

foreach ($roleAssignment in $list.RoleAssignments){
$xmlRoleAssignment = $xml.CreateElement(“RoleAssignment”)
$attr = $xml.CreateAttribute(“Member”)
$attr.Value = $roleAssignment.Member
[Void]$xmlRoleAssignment.SetAttributeNode($attr)

foreach($roleBinding in $roleAssignment.RoleDefinitionBindings){
if ($roleBinding.Name -ne “Limited Access”){
$xmlRoleBinding = $xml.CreateElement(“RoleBinding”)

$attr = $xml.CreateAttribute(“Name”)
$attr.Value = $roleBinding.Name
[Void]$xmlRoleBinding.SetAttributeNode($attr)
[Void]$xmlRoleAssignment.AppendChild($xmlRoleBinding)
}
}
[Void]$xmlRoleAssignments.AppendChild($xmlRoleAssignment)
}

[Void]$xmlList.AppendChild($xmlRoleAssignments)

$xmlFields = $xml.CreateElement(“Fields”)

for ($i=0; $i -lt $list.Fields.Count; $i++){
if ($list.Fields[$i].Hidden -eq 0){
$xmlField = $xml.CreateElement(“Field”)
$attr = $xml.CreateAttribute(“Title”)
$attr.Value = $list.Fields[$i].Title
[Void]$xmlField.SetAttributeNode($attr)

$attr = $xml.CreateAttribute(“Type”)
$attr.Value = $list.Fields[$i].Type
[Void]$xmlField.SetAttributeNode($attr)

$attr = $xml.CreateAttribute(“Group”)
$attr.Value = $list.Fields[$i].Group
[Void]$xmlField.SetAttributeNode($attr)

$attr = $xml.CreateAttribute(“Required”)
$attr.Value = $list.Fields[$i].Required
[Void]$xmlField.SetAttributeNode($attr)
[Void]$xmlFields.AppendChild($xmlField)
}
}
[Void]$xmlList.AppendChild($xmlFields)
$xmlViews = $xml.CreateElement(“Views”)

for ($i=0; $i -lt $list.Views.Count; $i++){
$xmlView = $xml.CreateElement(“View”)

$attr = $xml.CreateAttribute(“Title”)
$attr.Value = $list.Views[$i].Title
[Void]$xmlView.SetAttributeNode($attr)

$attr = $xml.CreateAttribute(“Query”)
$attr.Value = $list.Views[$i].Query
[Void]$xmlView.SetAttributeNode($attr)

foreach ($viewField in $list.Views[$i].ViewFields){
$xmlViewField = $xml.CreateElement(“ViewField”)
$xmlViewField.InnerXml = $viewField
[Void]$xmlView.AppendChild($xmlViewField)
}

[Void]$xmlViews.AppendChild($xmlView)
}

[Void]$xmlList.AppendChild($xmlViews)
[Void]$xmlLists.AppendChild($xmlList)
}
[Void]$xmlWeb.AppendChild($xmlLists)
}
[Void]$xml[“Websites”].AppendChild($xmlWeb)
$web.Dispose()
}

$site.Dispose()

$xml.Save(“C:\Aurelium\Powershell\” + $filename)
$xml.Save(“C:\Aurelium\Powershell\” + $filename2)
}

if($help) { GetHelp; Continue }
if($url) { EnumSiteStructure -Url $url}
else { GetHelp; Continue }

 

Posted in Sharepoint | Tagged , | Leave a comment

ASP.NET C# Html Encoding/Decoding in combination with QueryStrings


I bumped into some issues today concerning with html encoding in querystrings combined with special characters…

Original url: http://yoursharepoint/_layouts/projectx/viewdetail.aspx?ItemID=5&DataPath=RootNode/level1/cliënt
QueryString – “DataPath”= “RootNode/Level1/cliënt” (NOT OK)

I used the method html.Encode() en still the problem occur

Original url: http://yoursharepoint/_layouts/projectx/viewdetail.aspx?ItemID=5&DataPath=RootNode/level1/cliënt
QueryString – “DataPath” = “RootNode/Level1/cli” (NOT OK)

Solution:

// when creating the url
string url = Server.HtmlEncode(“http://yoursharepoint/_layouts/projectx/viewdetail.aspx?ItemID=5&DataPath=RootNode/level1/cliënt).Replace(“&#”, “-amp-“)

// when checking the querystring
string dataPath = HttpUtility.HtmlDecode(Server.UrlDecode(Request.QueryString[“DataPath”].Replace(“-amp-“, “&#”)));

QueryString – “DataPath” = “RootNode/Level1/cliënt” (OK)

Posted in Geen categorie | 1 Comment

XmlDataSource – Treeview databind based on Parent – Child xml file


Do you need to implement an ASP:TreeView in you website based on a xml file with a nice nested Parent – Child structure? I think that everyone already wrote, at least one time in his life, a recursive function to accomplish this but this can be better 🙂

I found a very good post on this matter: http://www.4guysfromrolla.com/articles/042308-1.aspx

I wasn’t aware of this solution, so I learned something! 🙂

ASPX Page:

<asp:XmlDataSourceID=”xmlData”runat=”server”/>
<asp:TreeViewID=”trvGeoMap”runat=”server”OnSelectedNodeChanged=”trvGeoMap_OnSelectedNodeChanged”AutoGenerateDataBindings=”false”DataSourceID=”xmlData”EnableViewState=”true”>
<DataBindings>
<asp:TreeNodeBindingDataMember=”GeoMap”Text=”Detail”/>
<asp:TreeNodeBindingDataMember=”Node”FormatString=”{0}”TextField=”title”ImageUrl=”/_layouts/images/EMMTerm.png”/>
</DataBindings>
</asp:TreeView>

Xml-File:

<GeoMap>
<Node title=”France”>
<Node title=”Paris”>
<FieldRef title=”Population” value=”2,211,297″/>
</Node>
</Node>
<Node title=”Belgium”>
<Node title=”Antwerp”>
<FieldRef title=”Population” value=”507,050″/>
</Node>
<Node title=”Brussel”>
<FieldRef title=”Population” value=”1,800,000″/>
</Node>
</Node>
</GeoMap>

Code-Behind (the xml-file is located in SharePoint ;-))

using (SPWeb spWeb = SPContext.Current.Site.OpenWeb(“KB”))
{
SPFile spFile = spWeb.GetFile(“/kb/Templates/DocDetail_TreeFile.xml”);
StreamReader reader = new StreamReader(spFile.OpenBinaryStream());
xmlData.Data = reader.ReadToEnd();
trvFiches.DataBind();
}

Posted in Geen categorie | Tagged | Leave a comment