Thursday, October 24, 2013

SharePoint 2013: Request Management

Yesterday I posted about the Distributed Cache and that I got frustrated with it. So I disabled it on one server. Turns out, it wasn't the smartest idea to simply shut the service down.  Yesterday night I saw a lot, and I mean A LOT!, errors like this one:

This does not sound good. I checked the Webapplications from the description, but they worked fine, as far as I can tell. Problem is the Service "Request Management", which is still running.
I stopped the service the service, did an IIS reset, waited a couple of minutes and checked the EventLogs again. I got one last message per Webapplication, like this one:

I'd say it works. If I encounter any more problems, I'll post on my blog and share this information. Until then my farm finally works without major issues.

SharePoint 2013: Distributed Cache

Wow! I found my new enemy within the SharePoint world: Distributed Cache. Please step down from your throne, User Profile Service.
But how was that even possible?
Well, it started with a small, new SharePoint 2013 Farm, just enough power to run as a testing system. I wanted to use the Distributed Cache on the App as well as on the WFE. But everytime I tried to start the Service under /_admin/Server.aspx ( CA -> System Settings -> Manage services on server) I got this message:

So, what did I do? A lot. The next steps are the ones, that "fixed" my problem, which means, that I will not use Distributed Cache on my WFE but only on the App Server.

TechNet suggests that I should repair the Cache and be done with. So I used their example:
$s = Get-SPServiceInstance GUID
But that did nothing, except throwing a couple of errors. Maybe I got the GUID wrong, so I tried it without one:
$instanceName = "SPDistributedCacheService Name=AppFabricCachingService"
$serviceInstance = Get-SPServiceInstance | ? {( $_.service.tostring()) –eq $instanceName –and ($ –eq $env:computername}
 At least I didn't get an error. I checked id the ServerInstance was really removed:
Get-SPServiceInstance >> C:\Service.txt

Well. It's just the App Server there. And I'm honestly not sure if that is the way it's supposed to look like. But it would make sense, because I still have a ServerInstance running on my App Server. To be sure, that I don't have anything running, I'm trying to stop the service with this command:
Stop-SPDistributedCacheServiceInstance -Graceful

I'd say: I can't stop the ServiceInstance, because it does not exist. Which is great! It is gone, finally.
And now, we can remove the Service Instance:
I got no error message while writing this blogpost. When I was trying this before, I got a lot of errors, most of them were about "cachehostinfo is null".
If you check your CA now, you will notice, that the Distributed Cache Service was removed from the services on service page of the server, the WFE in my case.
Next step would be to add a ServiceInstance again, which you have to do with this code:
Finally I got another error message, it's been a while. Also I'm starting to hate Distributed Cache.

I guess it's in use because of AppFabric. But why should that be a problem? Distributed Cache is based on AppFabric and as far as I know, you are not supposed to configure anything in AppFabric. So: what now?
In my case it meant to retrace my step, right to where I tried to add the ServiceInstance again.

After that, I tried all those links at the bottom. But none helped me with this problem. I tried for two days to get the Distributed Cache to work on my WFE, after that I gave up. I stop the ServiceInstance, removed the ServiceInstance and unregistered the WFE from the Cache:
Unregister-CacheHost -HostName 'HName' -Provider 'PName' -ConnectionString 'CString'
You can find the information for provider and connectionstring in the registry of the working server:
 Don't forget to do an IIS reset or you might get shocked from the IIS screen.

If anyone has a different solution, that is not one of the many posted below, please feel free to contact me!

And here are the references used, which are a lot. But sadly none of them fixed my problem.

Wednesday, October 23, 2013

PowerShell: Get Certificates which are about to expired

I got a little error message in the EvenLog:
"Certificate for local system with Thumbprint XX  is about to expire or already expired."

And this is how I found the certificate:

Wednesday, October 16, 2013

SharePoint 2013: Change Distributed Cache Service Account

The code is simple:

$farm = Get-SPFarm
$cacheService = $farm.Services | where {$_.Name -eq "AppFabricCachingService"}
Write-Host $cacheService
$accnt = Get-SPManagedAccount -Identity "DOMAIN\ACCOUNTNAME"
Write-Host "Managed Account" $accnt
$cacheService.ProcessIdentity.CurrentIdentityType = "SpecificUser"
$cacheService.ProcessIdentity.ManagedAccount = $accnt
Write-Host "Now Updating"
Write-Host "Finished."

You will not need to use .Deploy() at the end, despite Microsoft using it.

Sunday, September 15, 2013

SharePoint 2013: Sign in as Different User

In SharePoint 2013 I was missing a feature: Sign in as Different User. After a quick search, I realized that this function isn't available anymore.

BUT! There is always a solution for problems like this.

The first one would be, to run IE with another user account, which is recommended for productive systems.

The other solution would be to manipulate the "Welcome.ascx" file.
1. Go to your 15 hive
3. Add this code snippet before you find the "ID_RequestAccess"-id
<SharePoint:MenuItemTemplate runat="server" ID="ID_LoginAsDifferentUser" Text="<%$Resources:wss,personalactions_loginasdifferentuser%>" Description="<%$Resources:wss,personalactions_loginasdifferentuserdescription%>" MenuGroupId="100" Sequence="100" UseShortId="true" />
But remember: use this only on a development system. 

Tuesday, September 10, 2013

SharePoint 2013: Deactivate / Disable "Send an email invitation"

This was and still is pretty frustrating. Microsoft sets a default value which doesn't seem to be used that much in businesses. So how do you deactivate this?

1. Go to:
"C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\TEMPLATE\LAYOUTS"
2. Search for a file named "AclInv.aspx"
3. Open that file and search for "id="chkSendEmailv15""
4. Change the value of "Checked" to "false"

Problem solved.

Friday, August 30, 2013

SharePoint 2010: Deactivate or enable BLOB Cache

The fastest way I think would be to edit the "web.config" file. Usually you can find that file under: "C:\inetpub\wwwroot\wss\VirtualDirectories\YOURPORT".
Click to enlarge
Open that file in Notepad and search for "blob". You will see this line:
Set the last parameter "enabled" to "false" to deactivate BLOB Cache. Set it on "true" to enable it.
Click to enlarge

Also you can change which files should be part of the BLOB cache simply by changing the filetypes in the "path" parameter.
Click to enlarge

I changed the "path" parameter after one of the CUs for SharePoint 2010 was throwing a lot of errors.

Wednesday, August 28, 2013

Flush the SharePoint 2010 blob cache

The blob cache is meant to save database access, because binary files (like images) will be stored on the webfrontend server. Sometimes you will run into problems like I did a couple of days ago.
So I had to flush my cache with this little script:

$webApp = Get-SPWebApplication 'WEBAPP'
An you're done. Pretty easy.

Wednesday, July 17, 2013

SharePoint 2010: Rename a SharePoint 2010 farm

To rename an existing SharePoint 2010 farm you can use this PowerShell command:
Rename-SPServer [oldServername] -Name [newServername]
Before you change the host name of your servers, you will need to use this command!

The same thing can be achieved by using the stsadm command:
stsadm -o renameserver -oldservername [oldNAME] -newservername [newNAME]
The stsadm command can be used before or after the servernames have been changed.

Monday, July 15, 2013

SharePoint 2010: FSSPUsernameFilter.dll failed to load

While I was restoring my SharePoint farm I got this little error:
"The HTTP Filter DLL 'C:\Program Files\Microsoft Forefront Protection\FSSPUsernameFilter.dll' failed to load. The data is the error."

"The data is the error" sounds like something straight from The Matrix, but don't worry, we're still talking about Microsoft Tools. So how do you fix that?

Solution A)
1. Check which account is used to run the IIS pool for your SharePoint WebApp.
2. Check the permissions on your Forefront installations directory and grant full access to the mentioned account.
3. Maybe you also need to grant full access to the "FSSUPUsernameFilter.dll". But this is something you have to test for yourself. Sometimes it works without permissions on file level, other times it did not work for me.

Solution B)
1. Remove the filter:
2. Deactivate the anti-virus scan:

Depending on your users, the second solution might not be the smartest idea, but at least you can get the farm running while you are maybe reinstalling Forefront.

Solution C)
Reinstall Forefront. This is your last resort. Make sure that every Forefront file is removed and install the application again.

SharePoint 2010: Could not load all ISAPI filters

While I was restoring my SharePoint farm, I came across this error:
"Could not load all ISAPI filters for site 'SP-WebAPP'. Therefore site startup aborted."

To fix this issue simply run command "aspnet_regiis.exe -i".
You will be able to find that file in the "C:\WINOWS\Microsoft.NET\Framework64\v2.0.50727" directory.

Here's the MSDN article.

Tuesday, July 9, 2013

Infopath 2010: Delete a data binding

Just say you got a binding on a field in Infopath and you want to remove it. Here is how you can do it:

XPathNodeIterator statusDelete = xnMyForm.Select("/my:myFields/my:statusField", ns);
int count = statusDelete.Count;
if (statusDelete.Count > 0)
XPathNavigator delStatusDelete = xnMyForm.SelectSingleNode("/my:myFields/my:statusField", ns);

I simply use XPathNodeIterator, pick the field i want to remove, check if it exists und delete the first version of it. Because I can't use .DeleteSelf() I have to use XPatchNavigator for this part.

Wednesday, July 3, 2013

SharePoint 2010: SQL Server was not found after moving database

Another really entertaining error I got this week while using "Configuration Wizard", was this little gem:
Failed to register SharePoint services.
Now you might think: Wait a second! We already have a solution for that!
I thought so too, but after closer inspection of this error, I realized: My SQL server was missing! Well, not excactly missing, because he was running.

The scenario I encountered was this:
I had to switch my development system, got a new server name and forgot so stop every service and cut loose all ties between SQL and SharePoint. And I also made the mistake to transfer every database from my old system to my new system.

The solution:
Open "SQL Server Management Studio" and rename your existing SharePoint config database. The Configuration Wizard will now search for the old name, but will not find it and prompt you to create a new database. Problem solved.

Tuesday, July 2, 2013

SharePoint 2010: An exception of type System.Security.Cryptography.CryptographicException was thrown

While running the "Configuration Wizard" I encountered another problem.

"Exception - Failed to create the configuration database. An exception of type System.Security.Cryptography.CryptographicException was thrown. Additional exception information: The data is invalid."

Not that good, but also not that hard to fix.

The first thing you can try is:
Go to "%commonfiles%\Microsoft Shared\Webserver Extensions" and check the folder "14". Right-click on it, select properties and then click on the security tab. There you have to give the account "NETWORK SERVICE" full access.

If that didn't not help, you can try another solution:
Open your registry, go to "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Shared Tools/Web Server Extensions/14.0/Secure/FarmAdmin" and remove the registry entry there.

One time, the first solution fixed my problem, another time I needed both.

Monday, July 1, 2013

SharePoint 2010: Failed to register SharePoint services

After I was installing a new SharePoint farm, I got this message while running the "Configuration Wizard" (step 5):

Failed to register SharePoint services

I tried to restart the system, stopp and start the services again, but nothing worked. In the end I had to delete some entries in the registry.

1. So, click on "Start", "run" and type in "regedit". 
2. Now follow this path: HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Shared Tools/Web ServerExtensions/14.0/WSS/Services 
3. There I started to delete every failed service that poped up. 

Tuesday, June 18, 2013

Infopath 2010: Get groups from user

I just want to check if a user is part of a specific group. Well, that should be simple, right? I'm using SharePoint 2010, got an Active Directory Server somewhere and InfoPath 2010. All Users are working with authenticated accounts on their clients and have authenticated users while browsing SharePoint 2010. It should really be simple, right? I mean, come on! It's all Microsoft and all connected. Right?


The short version is: I ended up coding this little thing in C#:

PrincipalContext domain = new PrincipalContext(ContextType.Domain);
UserPrincipal userPrincipal = UserPrincipal.FindByIdentity(domain, User.UserName);

// set field "isMemberTxt" to "true"
string group = "YOURADGROUP";
GroupPrincipal groupPrincipal = GroupPrincipal.FindByIdentity(domain, group);
bool isMember = userPrincipal.IsMemberOf(groupPrincipal);

if (isMember == true)
xnMyForm.SelectSingleNode("/my:myFields/my:isMemberTxt", ns).SetValue("true");
catch (Exception ex)

This will check if the current user is a member of the group "YOURADGROUP" and it will also set the field "isMemberTxt" to true. IT worked for me, but it is not ideal, I you are searching for a no-code-solution like I do. But it's something!

So if I find a no-code-solution, I will post it here.

Friday, June 7, 2013

SharePoint 2010: Flush BLOB cache

Recently I needed to flush the BLOB cache. But how should I do that? Simple, just use the script below.
$WebApp = Get-SPWebApplication "WEBAPPNAME"
Write-Host "Flushed for WebApp:" $WebApp
After that, you flushed the BLOB cache.

Wednesday, March 27, 2013

SharePoint 2010: The expected version of the product was not found on the system.

While I was trying to install a new CU I encountered an error. It simply says that "the expected version of the product was not found on the system.". Problem is, that I am sure, I DO have an expected version installed.

So what to do now?

There is a cmd-command for that:


With "PACKAGE.BYPASS.DETECTION.CHECK=1" the installation will run smoothly without checking the package version. Worked for me, even Configuration Wizard shows no problem and the farm still runs all right.