Monday, May 24, 2010

Security trimmed list views with ease!

I didn’t know how if this could be done, so I did what came natural.  Poke around 'til I finally get an answer.  Usually I end up with a dead-end but today, I definitely found something of value.  It’s a lot more simple than what I originally thought.  Tools needed: SharePoint Designer and Notepad.  This could all be done within SPD but since it crashes on me, I tend to take my code offline, then paste it back into SPD, right before saving.

So where do we start?  How about cracking open the list that you’d like to create a secure view on.  I needed a way to create a secure view of a Gantt Chart and mash it up with a few other lists.  So since I didn’t know how to make a Gantt chart with a DVWP, I poked around a little.  I created a Gantt Chart view using the GUI.  When you save the view, there is a .aspx page that shows up within the Folder Navigation.  My custom view is cleverly called, PersonalViews.aspx


Once this view is created, you can open the page up and *reuse* all of that code somewhere else…  So, since I already have a Benchmarking Doc Library that uses custom permissions,  this will be a perfect place for my PersonalViews.aspx page.  After opening the page, click over to the code view and select all of the code.  This is where Notepad comes into play.  I take all of that code and paste it directly into a fresh Notepad .txt file.  That way I have all of that code within another program…  Just a preference, but we all have our ways ;-).  With all of that code, we can now navigate the GUI and delete the view we created.  There’s no need for it anymore and it’s best to delete the view within the GUI.  I’m not sure what happens if you just delete the .aspx page, but to be safe, use the GUI.  Why are we deleting what we just created?  Doesn’t that defeat the purpose?  NO!  We have all of the code that’s needed in Notepad, remember?  What we need to do now is create a new .aspx page within SPD.  I deleted all of the auto generated code:


We don’t need any of that gunking up our new view.  Now copy all of the code from Notepad into the code view of the .aspx page.  When this page renders, it’ll give you a nasty looking error:

SPD - ListViewError

I thought this was a show stopper, until I saved it in my secure location: Benchmarking Doc Library.  Here only the owners of the site are allowed to view.  I’ve tested logging in as many different users and even if they are allowed to view the Benchmarking Doc Library, if they don’t have explicit rights to this aspx page, they’ll get security trimmed.  List Views can now be security trimmed!!!  Also, you’ll notice within your list, the drop-down for all of the views has a new view.  It’s called whatever you named your aspx page.  However, when someone without rights to the page clicks on the view from the drop down, they’ll soon realize they are in the wrong spot:

Access Denied Error

If you use this and find more purposes for this, please drop a comment.  I’d like to hear about it.

Wednesday, May 12, 2010

Sharepoint Workflows - Failed on Start (retrying)

This ought to be a lot of *fun* troubleshooting.  It’s the biggest product that I support for my company and also, at times, the most complex.  As you may have already seen this Workflow Error: Failed on Start (retrying), I have not.  At least not from a well formed workflow.  I’ve seen this come from the accidental infinite loop, so with that aside, this has become a nasty problem for me.  Currently this is happening on all workflows, once it’s initiated.  I have workflows that fire when an item is created, some that only fire manually, and others that fire when the item has changed…  A digital medley of workflow love.  All of these are having the same problem, all at once.

Things that make you go HMMMMM

This has got to be from the recent upgrade I just went through.  I upgraded to SP2 because of another error I was getting with content types.  Go figure, move from one problem to another ;-).  Sometimes I feel stranded on an island, but then I turn to the Sharepoint Community for help and they are always right there.  Websites like, Stump the Panel, and I can’t forget Twitter!  Without these websites and the people that converse within them, I wouldn’t do SharePoint.  It’d be too much for just me to handle.

 The AH HA moment (More like well it’s fixed now, so I’ll move on)

Listed below are the errors I was able to pull from the ULS logs on my server.


05/11/2010 16:42:24.97*
w3wp.exe (0x208C)
Windows SharePoint Services
Workflow Infrastructure
...eExecutor(Guid instanceId, CreationContext context, WorkflowExecutor executor, WorkflowInstance workflowInstance) at System.Workflow.Runtime.WorkflowRuntime.Load(Guid key, CreationContext context, WorkflowInstance workflowInstance) at System.Workflow.Runtime.WorkflowRuntime.GetWorkflowExecutor(Guid instanceId, CreationContext context) at System.Workflow.Runtime.WorkflowRuntime.InternalCreateWorkflow(CreationContext context, Guid instanceId) at System.Workflow.Runtime.WorkflowRuntime.CreateWorkflow(Type workflowType, Dictionary`2 namedArgumentValues, Guid instanceId) at Microsoft.SharePoint.Workflow.SPWinOeHostServices.Send(SPWinOeWorkflow winoeworkflow, SPWorkflowEvent e) at Microsoft.SharePoint.Workflow.SPWinOeEngine.RunWorkflow(Guid trackingId, SPWorkflowHostServi...

05/11/2010 16:42:24.97*
w3wp.exe (0x208C)
Windows SharePoint Services
Workflow Infrastructure
...ce host, SPWorkflow workflow, Collection`1 events, TimeSpan timeOut)

05/11/2010 16:42:24.97
w3wp.exe (0x208C)
Windows SharePoint Services
Workflow Infrastructure
Engine RunWorkflow: System.Workflow.ComponentModel.Compiler.WorkflowValidationFailedException: The workflow failed validation. at System.Workflow.Runtime.WorkflowDefinitionDispenser.ValidateDefinition(Activity root, Boolean isNewType, ITypeProvider typeProvider) at System.Workflow.Runtime.WorkflowDefinitionDispenser.LoadRootActivity(Type workflowType, Boolean createDefinition, Boolean initForRuntime) at System.Workflow.Runtime.WorkflowDefinitionDispenser.MruCache.GetOrGenerateDefinition(Type type, String xomlText, String rulesText, Byte[] md5Codes, Boolean initForRuntime, Boolean& exist) at System.Workflow.Runtime.WorkflowDefinitionDispenser.GetRootActivity(Type workflowType, Boolean createNew, Boolean initForRuntime) at System.Workflow.Runtime.WorkflowRuntime.Initializ...

As I was gathering information to troubleshoot this error, suddenly, the workflows *just work*!  OH WOW!  Since I’m a big fan of “If it isn’t broke, don’t fix it.”, I’ll be leaving this alone for now.  If anyone has a clue as to how this could’ve happened, feel free to drop a comment.  Please note that all of my workflows are built in SPD only.  Nothing custom and no OOTB workflows have been built.  I’m sure I’ll be updating this article again…

This may be a fix:; specifically this command: Lodctr /R "c:\Windows\Microsoft.Net\Framework\v3.0\Windows Workflow Foundation\perfcounters.ini".
I'm not going to run it until the thing breaks again, so we'll have to wait.

Tuesday, May 11, 2010

Another Facebook #Fail

How many more of these privacy leaks must we endure from Facebook?  Here’s another hack that I was told about and have confirmed true.  I believe it’s fixed at this point, but for all of the millions of other Facebook notifications *THIS WORKS*

In the mail header of the email there is a very weak encryption in place:

X-Facebook: from zuckmail ([MjA5Ljg1LjIyNS4xMDQ=])

So all you have to do is decode the MIME base64 string:

$ perl -MMIME::Base64 -e 'print decode_base64("MjA5Ljg1LjIyNS4xMDQ=");' or just go to a base64 Decoder site.


It’s child’s play to track someone’s IP address right back to their front door step.  This is just another reason I’ve cancelled my Facebook account permanently.  As of this writing, I believe the hash does now only resolve to, but WTF?  This is simple stuff guys…

Monday, May 10, 2010

Batch Feature Installation w/ Logging (Expanded)

Michael Greene wrote an excellent script earlier today.  Since I like to try what I see, I took the script a bit further and added a bit more of logic.  You can see the original script here Batch Feature Installation w/ Logging.  I’ve added more logic to the URL input, EVENTCREATE, and it’ll install every .wsp that you have in the directory.  Here’s how to use this script:

  1. Copy and paste the script into a batch file
  2. Place the batch file in the directory that has all of your .wsp’s
  3. Run the batch file and type the URL of the Site Collection (don’t worry if you mistype the http:// portion of the URL, I have an error checker for that ;-) )

So what will this do? Add the solution(s), deploy the solution(s), install them, and activate all of them in one fell swoop.  Cool eh?  Great for deployment scenarios or setting up those test box vm’s.  Feel free to add more… As I’m posting this, I already have thought of a way to bulk add .stp’s.  Maybe another post?

@echo off
setlocal enabledelayedexpansion
color 0E
Title Auto .wsp Deploy
rem *******************  Deploys all .wsp's in the current directory to the Site Collection ***************************
rem ******************* How to use?  Put this batch file in the same directory as your .wsp's *********************
rem ******************* The script will find every .wsp and deploy it to the Site Collection of your choice ********
rem ******************* I guarantee this will destroy your sharepoint farm unless you know what this ***********
rem ******************* code does.  Please make sure you test this before production usage. *********************
rem ****************** Sets vars *********************************************************************************************
set "path=C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN\;%PATH%"
set _http=http://
set /P _inputURL="Please enter the url the site collection to activate the feature(s) to: "
rem ******************* Checks the URL and appends http:// if needed **************************************************
IF /I %_inputURL:~0,7% == %_http% (
echo URL is in correct format
set _URL=%_inputURL%
) ELSE (
set _URL=%_http%!_inputURL!
Echo ************* Finding .wsp files *************
for %%a in (*.wsp) do call :ROUTINE "%%a"
Echo Adding Solution
stsadm.exe -o addsolution -filename %1
Echo Deploying Solution
stsadm.exe -o deploysolution -name %1 -allowGacDeployment -immediate -force
Echo Installing Feature
stsadm.exe -o installfeature -name %~n1 -force
IF errorlevel == 0 (
EVENTCREATE /L System /T Success /SO "SharePoint" /ID 3 /D "%1 Installed"
) else (
EVENTCREATE /L System /T Error /SO "SharePoint" /ID 3 /D "%1 didn't install properly"
Echo Activating Feature
stsadm.exe -o activatefeature -name %~n1 -url %_URL% -force
IF errorlevel == 0 (
EVENTCREATE /L System /T Success /SO "SharePoint" /ID 4 /D "%1 Activated"
Echo Activation of feature %1 COMPLETE!
) else (
EVENTCREATE /L System /T Error /SO "SharePoint" /ID 4 /D "%1 didn't activate properly"
echo Running timer jobs to finish deployment
stsadm.exe -o  execadmsvcjobs
PING -n 12 -w 100 2>NUL | FIND "TTL=" >NUL

You can also copy the script from this link: Batch Feature Installation w/ Logging (Expanded)