Friday, June 4, 2010

.Net 4.0 Framework Evolution

As you must be aware that Microsoft has unveiled its latest Dotnet Framework 4.0, I just thought I should add some information and provide download links for .Net framework 4.0.

4.0 is a superset of older versions of framework but it is independent of 3.5 or any other older frameworks. It is a standalone package.It is independent due to its brand new CLR

The framework is constantly reviewed by MS. If you see the evolution of the framework, the 2.0, 3.0, 3.5 had been on the same CLR but it was much different from previous 1.1 Framework. The versions which followed 1.1 had vast modifications. And, now 4.0 has comeout as a new offspring as shown below:

There are various products such as Visual Studio 2010, SPS2010, BizTalk 2010, etc.. which are already based on this new 4.0 framework.So fire up your engines and try your hands by downloading the latest .Net 4.0 Framework Offline Setup package from this link download

Tuesday, June 1, 2010

Find the IP Address of the SharePoint 2007 User

Suppose you have a SharePoint website that is being accessed by a lot of users everyday (~1K users daily).

Now for some reason or the other you want to capture the client IP address of the end user accessing your MOSS web application.

Purposes could be like:

  • Reporting/Logging user IP address
  • Security purposes
  • Filtering content based on the client IP address
  • Getting the location of the user based on the client IP address
  • so on..
You could simply use HttpContext.Current.Request.UserHostAddress to get the IP address of a user.

This could be easily used in both ASP.Net applications as well as SharePoint development projects.

Saturday, May 29, 2010

Difference between SPWeb.Users, SPWeb.AllUsers, SPWeb.SiteUsers

MOSS 2007 offers 3 different user collections in the SPWeb object.
  • SPWeb.Users
    This represents the collection of users or user objects who have been explicitly assigned permissions in the Web site . This does not return users who have access through a group.

    Example (C#):
    SPUserCollection users = web.Users;
  • SPWeb.AllUsers
    This gives us the collection of user objects who are either members of the site collection or who have atleast navigated to the site as authenticated members of a domain group in the site.

    Example (C#):
    SPUserCollection users = web.AllUsers;
  • SPWeb.SiteUsers
    This is the collection of all users that belong to the site collection.

    Example (C#):
    SPUserCollection users = web.SiteUsers;
These terms tend to confuse us unless we really know the differences between each one of them.

So I thought it would be nice to write an article stating which is what. Hope this information helps you SharePoint 2007 developers.

Sunday, May 16, 2010

How to Fix Central Administration: Service Unavailable Issue?

While working on MOSS Servers, you all must have faced 2 common issues quite frequently
  1. You receive a "Cannot connect to the configuration database"
  2. Service Unavailable
Basically, the configuration database is where SP stores all information about the SharePoint 2007 installation and the server farm, hence, it is required for the Central Administration to work fine.

Suddenly while you are in the middle of your important SharePoint deployment or configuration, either of these issues will prop up and eat up lengthy hours. Even the easiest solutions to all SharePoint problems i.e. IISReset or Server restart also do not end your miseries.

Hence, I decided, lets apply TRY-CATCH-FINALLY on these issues for once-n-for-all here.


For Issue#1:

Try to run the SharePoint configuration wizard once, follow these steps for the same:

  1. Click Start, click Run, type cmd in the Open box, and then click OK.
  2. Change to the following directory:
    system drive\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\Bin
  3. Run the following command:
    psconfig -cmd upgrade -inplace b2b
The above steps should fix the issue, but if your problem still persists, then check the event logs of your server. Checking those logs will let you know issues such as -
  • Is your SQL server agent running?
  • Credentials (app pool permissions) used for connecting to SQL Server is working or failing?
  • Facing any network issues to be able to connect to DB?
    (this only applies if the SQL is applied on a separate box from MOSS 2007)
  • so on..
For Issue#2:

If even after carrying out the above suggestions, you are not able to track down the problem, then you could unprovision Central Administration and then reprovision it.

This could be easily done via an STSADM command given below:

stsadm.exe -o provisionservice -action start -servicetype Microsoft.SharePoint.Administration.SPWebService -servicename WSS_Administration
 
I sincerely hope this helps you all in fixing this critical MOSS 2007 Central Administration issue.

Wednesday, May 5, 2010

How to backup a DLL from GAC to another directory?

Recently, one of my friends came up with a requirement where she wanted to take a backup of an existing .Net assembly that was already deployed in Global Assembly Cache (GAC) earlier.

When she asked me this question..I thought to myself that this should not be so tough..well it proved so too at the end.

Finally, this is how it could be done (well..one way of achieving this!!)

If you go to Windows  Run Assembly you will see this screenshot













Now, go to the Command Prompt on your system and type
cd windows\assembly ENTER (Key)

Next, type GAC in the CMD prompt, hit ENTER

Suppose, you want to copy "Extensibility" DLL from GAC to another directory, then type cd Extensibility (you can type Ex and press Tab on your keyboard to navigate faster) to enter the folder hierarchy.

Note: This would be your custom DLL instead of "Extensibility"

Press cd + Tab (keyboard) and hit ENTER again.

Once there, we need to copy!!

In CMD window, type: copy extensibility.dll C:\myCustomDir. Hit ENTER key













Go and check in that directory, you will find the Extensibility dll nicely lazing around..

Hope this post helps you all SharePoint 2007 & Dotnet developers as well as admins in doing this simple but at times life-saving act.

Saturday, April 24, 2010

Extracting data from Sharepoint Version table

When using SharePoint 2007, if we turn the Version Control settings to On for a List/Library, then different versions of the file or listitem get stored in the Content DB.

There are multiple ways to retrieve this information:
  1. Using MOSS 2007 API
  2. Via Versions.asmx - An OOB SharePoint Webservice
  3. Or Querying the Docs & DocVersions table directly in using T-SQL statements
Now through SP API, you can try something like this -->
SPWeb web = new SPSite("your site url").OpenWeb();


SPList lib = web.Lists["your library"];


foreach (SPListItem item in lib.Items)


{


SPFile file=item.File


SPFileVersionCollection versions = file.Versions;


//Add your code to loop through the version collection & add custom logic here..


}


Coming to WebService approach:


SharePoint has a Versions.asmx web service to work with versions in document libraries.


For introduction, check out how to utilize this to get some information :
http://www.c-sharpcorner.com/UploadFile/klaus_salchner@hotmail.com/SharePointWS11152005045049AM/SharePointWS.aspx




Incase, you want to go ahead querying the SQL tables directly, then you could try a query as below:


SELECT DocVersions.version
FROM Docs INNER JOIN DocVersions ON DocVersions.Id = Docs.Id


Although it is not recommended that you query the SP DB directly. Any modifications or changes to the Content DB tables in unsupported.




Also the data is stored in UTF-8 Encoded format. After the query runs, it returns some data like this:
UIVersion




512
1024
1536
2048
512
1024
512


The above data is difficult to interpret in terms of Version numbers. Anyway, just to let you know


512 = version 1,
1024 =version 2,
1025 =version2.1,
2048= version 3,
1=version 0.1
and so on..


I guess the pattern is clear to you. Hope this article helps you.

Saturday, April 17, 2010

SharePoint List Title Column

Generally there are 2 things we like to do with our SharePoint custom list Title field viz. Rename or Hide
Before we do this, be aware of the importance of Title field
  • It gets the context menu by default
    Hence, if you hide it then, basically all the Context menu functionality is removed
  • As a result, you need to put the Edit button in all of your views just to edit the item
  • You also need to place your custom code to re-associate context menu
If you still want to continue, then moving on to Renaming Title.
  1. Go to the List settings
  2. Click on the Title field
  3. Save your changes
If you are looking for hiding your title field, then do the following :
  1. Go to the List settings
  2. Click the Advanced Settings link
  3. Next, selecting the Yes option button for the management of content types on this list
  4. Click on the Item link in the Content Types section
  5. Now, click on the name Title link and change the Column Setting to Hidden.
  6. Save your changes by clicking OK
This article gave simple configuration settings for hiding or renaming List Title field. Hope this helps

LinkWithin

Related Posts with Thumbnails