Monday, November 30, 2009

Item Level Security For SharePoint Document Libraries

Hi ,


after some long discussions with my collegues and by observations when I came to know that sharepoint document libraries don't have any UI to provide Item Level Security then I started thinking on this .
all we know that as in Sharepoint list we can set the read and write security by using UI in advanced settings and like this





but in case of SPDocumentLibrary things are in some different way
but I found one way by using custom solution for this
this can be done like:

actually there are some read and write security bits available with the SPList and SPDocumentLibrary.
by setting those with proper valued we can manage ItemLevelSecurity
  • Read Security
    1 - All users have Read access to all items.
    2 - Users have Read access only to items that they create.
  • Write security
    1 — All users can modify all items.
    2 — Users can modify only items that they create.
    4 — Users cannot modify any list item.

more details can be found here Read Security and Write Security

Get SharePoint WebApplication/Application Pool owner's password

Hi All,
I was trying to get the username and the password for the sharepoint webapplication owner.
after long searching in this thing I came up with one short custom solution and this can be done like this:
SPWebApplication webApp = SPContext.Current.Site.WebApplication; string userName =webApp.ApplicationPool.Username;
string password == webApp.ApplicationPool.Password;

this gets the username and password of the Application Pool Creator for web application

Wednesday, September 16, 2009

Exciting Tool - stsadm

Hello All,

We all know that sharepoint central administration is the great UI which allows us to to all administration operation for the sharepoint.

but there is something more powerful command line tool in sharepoint known as STSADM.

location:- 12\BIN\STSADM.EXE

here is the link to all stsadm commands : all stsadm commands

there is some thing called customizationof these commands.

gl-tool is the great tool which is customized stsadm commands and allows you more power.
visit this link to know more

Playing Flash (.swf) Files in the SharePoint

Hello All,

actually I was trying my hands on the playing the animated images on the sharepoint web pages and was successful to show animated .gif files on web page.

so , I was thinking to play some more animations on the sharepoint site without use of any other custom web part.
what all I wanted was to play the flash file on sharepoint site without using video and other webparts.

so we can do this by using very useful webpart in sharepoint that is Content Editor Webpart.

what all you need to do is:


Upload the flash video file to the any document Library of the website open video file from document library and copy url.


1. open your page in the edit mode
2. add the content editor webpart on page

3. click on modify shared properties of the content editor webpart

4. open the tool pane and open source editor

5. write this code inside the source editor and you are done!!



<object width="1000" height="100">
<embed src="url to .swf file="1000" height="100"></embed>
</object>


(you can adjust height and width of the flash accordingly)

Thursday, September 10, 2009

Working with SharePoint Item Events

Hello All,

before some days I was working with the SharePoint list items and their events.

I just wanted to add small suggestion here that while working with the SPItemEventReceiver class or with the class that inherits from SPItemEventReceiver, we oftenly override the methods like

ItemAdding , ItemAdded, ItemUpdating, ItemUpdated.....etc

so many times scenario comes that we need to update something in the list and on some event but other events are stopping that
so to avoid this error

use

this.DisableEventFiring();
//update list or any listitem here
this.EnableEventFiring();

this works fine and avoids error.

please let me know If you find any improvement to be done in this.

Get HTML of .aspx page

Hello All,

before some days I was working with the .aspx pages and got in the situation that I needed the source of the page from code.

I am posting this small code snippet might be useful for others also

(Note:- There might be some issue while getting html source from the web page due to some network settings like proxies and secure sockets.)

//this creates a request to a web page.

HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("url of webpage");

//use this for obtaining settings of network

request.AuthenticationLevel = System.Net.Security.AuthenticationLevel.None;

request.Credentials = System.Net.CredentialCache.DefaultCredentials;

HttpWebResponse responce = (HttpWebResponse)request.GetResponse();
Encoding encoding = Encoding.GetEncoding(responce.CharacterSet);

//gets responce in the format of stream

Stream stream = responce.GetResponseStream();

//use StreamReader to read the stream contents


StreamReader reader = new StreamReader(stream, encoding);

string content = reader.ReadToEnd();

then you can use this obtained string content for any purpose like writing to a file.

Please suggest me If you find some improvements to be done in this.


Thursday, August 27, 2009

SharePoint Tool - wspbuilder

Hello All,
one of great tool which I know in sharepoint development is wspbuilder.
It is console application that creates SharePoint Solutions files based on a folder structure.
WSPBuilder will automatically traverse a "12" folder structure and creates a SharePoint solution manifest.xml and the wsp file based on the files it finds. Therefore you do not need the knowledge of how to create a solution manifest.xml and wsp file any more. The folder structure that WSPBuilder uses to build the wsp file is actually the same folder stucture you will find in: "%Program Files%\Common Files\Microsoft Shared\web server extensions\12". So all that you have to do, is the create a \12 folder in your project and add your files to that folder matching the same structure as if you where to put them directly into the "%Program Files%\Common Files\Microsoft Shared\web server extensions\12" folder manually.

this tool easily generates wsp file which can be easily deployed on server.
so makes development easy!!

Sharepoint site and Farm Backup Stratergies

Hello All,
since many days I was searching on the way to perform sharepoint site backup and restore.
I came across many documents and many web pages containing such Information.
Finally I am summarizing the whole story which is very powerful.


Sharepoint BackUp/Restore Using Central Administration Tool:

As we all know that sharepoint central administration tool (UI) is a great tool which comes by default with WSS and MOSS.
for taking backup of the site or the entire farm you just have to follow simple steps:

Farm Backup:

1. open the SharePoint Central Administration Web site, on the Operations page, in the Backup and 2.Restore section, click Perform a Backup.
3. Select Component to Backup page, select Farm, and then click Continue to Backup Options.
4. On the Select Backup Options page:
5. In the Backup Content section, ensure that Farm is displayed.
6. In the Type of Backup section, select Full.
7. In the Backup File Location section, type the Universal Naming Convention (UNC) path to the backup folder.
8. Click OK.

and thats done!! you will have back up of entire farm with you!!

Farm Restore:

1. Open SharePoint Central Administration Web site, on the Operations page, in the Backup and Restore section, click Restore from Backup.
2. On the Select Backup Location page, in the Backup File Location section, type the Universal Naming Convention (UNC) path to the backup folder.
3. On the Select Backup Package to Restore page, select the backup file you want to use to restore, and then click Continue Restore Process.
4. On the Select Component to Restore page, select the farm you want to restore, and then click Continue Restore Process.
5. On the Select Restore Options page:
6. In the Restore Component section, Ensure that Farm is displayed.
7. In the Restore Options section, select Same configuration.A message is displayed, notifying you that the current farm will be overwritten. Click OK.
8. In the Login Names and Passwords section, type the user name and password for your Farm Administrators account.
9. In the New Names section, type new names and URLs for each component, or accept the default values.
10. Click OK.

(Note:- If you facing any error like backup/restore job already in process then go to operations tab in central administration and navigate to timer job page, see If there exists any backup/restore job, delete that job and try again with backup/restore process.)


Backup/Restore using Command Line Tool :- stsadm

Taking backup using Central Administration tool might be easy because of UI but the command line tool i.e. stsadm.exe offers you some great feature to work with. Lets have a look.


For site collection backup

stsadm -o backup
-url
-filename
[-nositelock]
[-overwrite]

For catastrophic backup (Farm's backup)

stsadm -o backup
-directory
-backupmethod
[-force]
[-item]
[-percentage]
[-backupthreads]
[-showtree]
[-quiet]

Lets have look at the parameters:
url :- URL of the site collection that you want to back up
filename :- Name of the backup file (.bak)
nositelock :- Specifies that the site collection lock during a site collection backup is not set to read-only.
overwrite :- To overwrite an existing backup file.
directory :- The path where Microsoft Office SharePoint Server 2007 should store the backup package it generates. (mostly used in case of entire farm's backup)
backupmethod :- (Full or differential) :- Type of backup file to be created. The values are full or differential.
A full backup is a backup of all the selected data. A differential backup is a backup of all the selected data that has changed since the last full backup.
force :- Ignores the disk space check and proceeds with the backup.
item :- Indicates which part of the farm should be backed up.
percentage :- Requests backup operation progress updates to be displayed in increments of that percentage
backupthreads :- An integer value between 1 and 10 to show the number of threads that should be used during the backup. For Windows SharePoint Services, the recommended value is 3
threads.
showtree :- Displays which objects in the farm will be backed up based on the other parameters passed to the backup operation, namely the -item parameter.
quiet :- Suppresses the output of backup progress information to the display window.

For site collection restore

stsadm -o restore
-url
-filename
[-hostheaderwebapplicationurl]
[-overwrite]

For catastrophic restore


stsadm -o restore
-directory
-restoremethod
[-backupid]
[-item]
[-percentage]
[-showtree]
[-suppressprompt]
[-username]
[-password]
[-newdatabaseserver]
[-preservechangelog]
[-quiet]

Wednesday, August 19, 2009

My Most Faviourite Poem

He worked by day And toiled by night.
He gave up play And some delight.
Dry books he read,New things to learn.
And forged ahead,Success to earn.
He plodded on with Faith and pluck;
And when he won,Men called it luck.

Yeahh!! I have a blog now :D

Hello Friends,
Since many days I was having a thought revolving in my mind that I should have a blog!!
and today I have created one, and this is the first post from me!!
actually this feels nice to have a blog to share your ideas and thoughts across your all friends.
I have created this blog to have share some my thoughts.
so be up to date and have nice time!!
see you in my next post!!