Thursday, April 30, 2009

How to write Custom Audit Entries in WSS3.0?

Last year i attend Ted's training on WSS3.0. He given all Lab and whitepapers which are published by him.I am reading one by one.
One article on Audit logging is awasome.
I would like to post the summary of the article.
Audit logs detailing events that track data such as which users viewed and updated records and documents, and when these events occurred.
Microsoft Windows SharePoint Services 3.0 (WSS 3.0) and Microsoft Office SharePoint Server 2007 (MOSS) provide support for auditing user access to pages, content, and documents, and includes auditable events such as viewing and updating.
While WSS provides the basic auditing mechanisms, MOSS adds value by supplying an administrative user interface that allows auditing at the site collection level. MOSS goes even further and enables auditing at the list or document library level, and control over what types of events should be recorded in the audit log. MOSS also provides a reporting function that uses Microsoft® Office Excel® workbooks to display and keep records of audit logs. Therefore, MOSS allows you to take advantage of the WSS auditing support without having to write any custom code.
// turn on auditing flags to a list
SPSite siteCollection = new SPSite("http://LitwareServer1");
SPWeb site = siteCollection.OpenWeb();
SPList list = site.Lists["Proposals"];
list.Audit.AuditFlags = SPAuditMaskType.View
SPAuditMaskType.Update
SPAuditMaskType.Delete;
list.Audit.Update();
The code is written to read the audit log of the current site collection by creating an SPAuditQuery object.
SPAuditQuery wssQuery = new SPAuditQuery(siteColl);
SPAuditEntryCollection auditCol = siteColl.Audit.GetEntries(wssQuery);

As you examine the implementation of the code that reads information from the WSS audit log, observe how it retrieves user names. The WSS audit log tracks user IDs but not user names. After you have obtained a user ID, you can retrieve the associated user name using the GetByID method on the SiteUser collection, which is exposed as a property of the top-level site. Make sure you use the SiteUsers collection; do not confuse this with the User collection, which does not provide the same results.
string GetUserNameById(int UserId, SPWeb site) {
return site.SiteUsers.GetByID(UserId).Name;
//return site.Users.GetByID(UserId).Name; - YOU CANNOT USE SPWeb.Users collection here

}

Writing custom audit entry
item.Audit.WriteAuditEvent(SPAuditEventType.Custom, "CustomViewAuditEvent", "");

Friday, April 24, 2009

How to create your own custom STSADM Command?

I have the requirement like to extend STSADM command.
My ECM guru has posted excellent piece about this topic.
There are two steps:
1) Implement the ISPStsadmCommand interface
2) Create an XML file in the 12\CONFIG folder that describes your commands
ISPStsadmCommand interface consists following 2 methods .

The full story was written by Holiday


Thursday, April 23, 2009

WITH (NOLOCK) directive in SQL

I am poor at DataBase level. luckly i have a requirement to work on SSRS2005. I used to see the existing reports , queries n i found new directive called WITH(NOLOCK) .
I had discussed with my RM n has cleared my doubts and explained senario(s) n Tips.
I would like to explain the summary .
"Same kind of reports r accessing multiple users in the bussiness hours.If i lock the records while retiving reports the remaining users should wait untill the task completion.Insted of that we r prefering WITH(NOLOCK) directive before a table in a query"
The following link is very useful for me.
http://blogs.neudesic.com/blogs/phil_scott/archive/2005/12/05/11.aspx

Wednesday, April 22, 2009

CAML.NET IntelliSense for SharePoint

As a MOSS Hunter i know the CAML very well. But still i have been facing littile bit trouble on CAML usage.
But last week i have attended ECM training from Tedpattison. John has Announced the CAML.NET IntelliSense project.
Using this installation in our box our daily task will be easy.

Tuesday, April 21, 2009

SharePoint Designer 2007 - It's FREE!

In case you haven't heard, Microsoft Office SharePoint Designer 2007 is now available as a FREE download.
Check it out from Asif.

Longitude for sharepoint

My best friend Sanjay has been working on Longitude. I go through his blog and find some cool stuff on MOSS Development.

Tuesday, April 14, 2009

How to increase the bandwidth of the Web-enabled forms?

Ans: Set Form Session State to Form view
Goto Central Administration > Application Management > Configure InfoPath Forms Services at the bottom sharepoint given the follwoing option

How to ensure the data from web services is accessible into InfoPath 2007 Browser Forms

I am searching that how to enable the web service proxy for user forms. I got the idea once i red the following post.
http://blogs.msdn.com/infopath/archive/2006/10/02/Data-Connections-in-Browser-Forms.aspx

How to migrate of a MCMS 2002 to our MOSS 2007 environment?

As per my MCTS prepartion for Configuration i go through some of migration tool.
We need to migration tasks that need to be completed. For this purpose in CodePlex some tools r avilable. And one fine article on MSDN. Go through the following link.
http://msdn.microsoft.com/en-us/library/aa480227.aspx

Friday, April 10, 2009

How to deploy SSRS report into MOSS environment?

I got the chance to work on SSRS.I developed Emp Details Page Template and Leave Tracking details for one of my stakeholder. The data is storing in a Data Base Table. Using these data I am going to generate various reports. So as per my first attempt I did one sample report and I would like to explain how to deploy into Sharepoint environment.

Once i deploy the report it has show like the following shot.

Thursday, April 9, 2009

Random Question using Survay's in WSS3.0?

For my Quiz application my requirement is getting random question from a survay list in WSS3.O. I google lot and met few MVPs. But i didn't get a +ve reply.I would like to give one of the MVP Mr SS.Ahmed's reply.

RenderPattern Element in WSS3.0

My Stakeholder has one of the tricky requirement on DisplayPattern .
I created a Quiz application . In that I have been tracking the results in a list. The list contains the following datails.
1) Who attend the exam.
2) Wt is percentage he/she got.
3) Wt time.
4) Result.
The issue is once the user got failed the value should be in red color.

I dig a lot and i found one sample from Ted Pattison's code. I am giving a sample which i did in my previous app. But that is a custom field.

Thursday, April 2, 2009

WCM Training

I got the chance to attend WCM Traning from Andrew Connell.This was Awesome.I learned lot from this cource.

Understanding Field Controls and Web Parts in SharePoint Server 2007 Publishing Sites

I red a new article which was Published by Andrew Connell
I prepared a small notes on this article....
The CEWP doesn't store version history, it doesn't participate in any publishing approval workflow and it does store absolute URLs rather than relative URLs. Even if you enter a relative URL into the editor, it will be converted to an absolute URL. The rich text editor that the Publishing HTML field type is tied to does not convert relative URLs to absolute URLs.
What are the differences between Web Parts & Field Controls and when to use them?
Field controls differ from Web Parts in two fundamental ways: who has control over the layout and structure of the page, who has control over the content on the page, and where the content is stored.
Web Parts
Beginning with Windows SharePoint Services 3.0 and Office SharePoint Server 2007, the ASP.NET 2.0 Web Part framework manages all of this on behalf of Windows SharePoint Services. This means that Windows SharePoint Services no longer controls which Web Parts are on the page or their locations on the page, and does not manage the content stored in the Web Parts. The content and configuration data for Web Parts, known as personalization data, is stored in the ASP.NET 2.0 personalization data store. In Windows SharePoint Services 3.0 sites, this personalization data store is kept in the SharePoint content database.
It is important to understand how Web Parts work within ASP.NET 2.0 and Windows SharePoint Services 3.0 sites. When a Web Part is added to a page in a SharePoint site, ASP.NET 2.0 inserts a block of XML into the Web Part zone that notifies ASP.NET 2.0 about which Web Part to load and what data to assign to all of the Web Part's public properties. When the page is requested, the ASP.NET 2.0 Web Part framework examines this XML to find the Web Part to load (by assembly and class), loads the control, and sets the values of all the public properties. Finally, the page rendering process renders the Web Part.
This XML data is stored in the ASP.NET 2.0 personalization data store—not with the page itself. This means the personalization data is tied to the page's URL and user context, not to the page or version of the current page (as in a SharePoint Server publishing site).
The advantage to using Web Parts for content is that you can personalize the content on a user-by-user basis if the publishing site has a way to uniquely identify users, such as by requiring a logon.
Field Controls
A field control pulls data (in display mode) from a particular column in a list item and writes back to that column in edit mode. Pages in a Publishing site are stored as items in a list; the Pages list. Because they are in a list, they can leverage all the benefits a list has to provide, but visioning & history is the most important here. When a developer places a field control on a page layout, they have the ultimate control of where it is placed on the page.
Field controls provide developers and designers a higher level of control over content pages than Web Parts do. Content owners can only add and manage content within field controls. They cannot move field controls on the page or override the settings set by developers.
What is the significance?
• Consistent lookand feel (A corporate brand)
• Structured organization of contentand a versioned and/or historical record of the content.
If structure and history is important on your site, you should ONLY consider field controls for your content. If you want to have a more relaxed authoring environment where structure & history isn't important, Web Parts are better.
To summarize: the content in Web Parts is not versioned and there is no history, but the content in field controls is versioned & a history is retained
And My Guru explained how to add Safecontrol entries into Web.config file ….