So you want the world to see your sites Usage data, except you have a problem, access to the reports is only provided to the administrators of a site. Well you could give everyone administrator rights and you could gnaw off your own foot but neither is a good idea the administration one less so.
So I know I’ll do this in a web part and just call some impersonation stuff, you know that WindowsImpersonationContext object will do fine. So you build a part, do the “Mike Yarwood” and whoooah now no one ‘cept you, can see your site.
So this is the point you get stuck, and think “google”. After some searching I found Patrick Tisseghem’s blog with a post on this very subject.
First he solves your “Bang” no one see this, which could come in handy for Admin only web parts
SPControl.GetContextSite(HttpContext.Current).CatchAccessDeniedException = false;
But then comes up with good a old .NET running under COM+ example. His example shows a webs.count usage, but UsageData works in the same way.
Another helpful article I found later in trying to get this mare to work ( I just love mixing Sharepoint, Gac, Com+ IISReset is your friend!!!) was found here. This article fills in some blanks about auto configuring the COM+ Application settings, What it doesn’t do is set the correct user, Make sure you go and set this else it will not work, make sure the user has sharepoint admin access to ALL areas, cos this is a web part anyone can use remember.
When using GetUsageData, remember that this information is gathered once a day so plenty of Caching opportunities here, don’t keep doing cross process communication as this has to be a Server component not a library one.
One thing that does puzzle me, is why dont my components spin in the Component Services tool when called ?
So Why ain’t I spinning then ? (and yes timeout of 3 minutes is set)
And one more thing, try at your own risk. Im not saying it doesn’t work, just that you should investigate whats happening before you do it.
tags: sharepoint, webparts, GetUsageData, evil+voodoo+in+sharepoint
The problem with attempting to gnaw off one’s own feet is that it requires considerable double-jointedness and is almost impossible without being slim and flexible. Believe me, I’ve tried.
It’s much easier to gnaw off a hand, although even that requires teeth that are both sharp and strong.
For a considered approach to limb removal in times of Sharepoint crisis, it might be best to have a variety of sharp tools to hand, viz: hedge trimmers, bread knives, a scythe, a pen knife, and my personal favourite, a nice sharp chisel (although of course you’d also need a mallet for that).
It’s also a good idea to plan beforehand what you’re going to do with the limb afterwards, as you’ll inevitably be distracted by clearing up the mess.
And of course missing from any shopping list of items required is
A piece of string.
Hi,
I did a web part similar to the Odometer web part. Mine displayed the number of list, the number of subsites and the folder Size. However, I would like to add:
Total Hits:
Most recent recent day:
just like you did on the Odometer web part. I couldn’t find any good example online to follow. I was wondering if you can help me add these two functionalities on my web part I would really appreciate.
Here is my email address: hnazaire@gmail.com
Thanks for your time.
Regards,
Harold
Sorry Harold I just don’t have the time to help, I barely have the time to post recently.
Also I take it this would be wss3 I would need to learn all about usage data in that before helping too so
good luck with this.