Friday, November 28, 2008

CustomGroup and CustomAction in central admin application page using featurepage

In central admin, there is option to add new group and action in "Operation" page like :Topology".

Here is the xml file that can added new custom group in the central administration.

You can installed as new feature for that and activated features in site feature.

feature.xml

<Feature Id="56FD5FEC-4FE9-4970-B1B6-20580B2ECD1B"   Title="Test Group Page"
Description="Test Group Page."   Version="1.0.0.0"      Scope="Web"    Hidden="false"
DefaultResourceFile="core" xmlns="http://schemas.microsoft.com/sharepoint/">
                <ElementManifests >
                                <ElementManifest Location="element.xml" />
                </ElementManifests>
</Feature>

 
element.xml
 

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
       <CustomActionGroup Id="{6C3A6045-5F34-4203-80E7-C9DD90801835}" Title="Test Group"     Location="Microsoft.SharePoint.Administration.Operations"  Sequence="100" />
                <CustomAction   Id="{EA6E9E68-32C6-47f2-9CF3-07D7A496623D}"   Title="Test Page"                 Location="Microsoft.SharePoint.Administration.Operations"
                GroupId="{6C3A6045-5F34-4203-80E7-C9DD90801835}"
                RequireSiteAdministrator="TRUE"
                Sequence="10">

       <UrlAction Url="/_controltemplates/ApplicationPage.aspx"/>
               </CustomAction>
</Elements>

 Links :



Sunday, November 23, 2008

Using the Contact Selector in Infopath 2007

How to Deploy SharePoint WebParts

There are several ways to skin the Webparts deployment cat, each with a few pluses and minuses.

Method 1 - manual

  • Copy assembly DLL to either
    - /bin directory for a given IIS virtual server (e.g., c:\inetpub\wwwroot\bin)
    - Global Assembly Cache (e.g., c:\windows\assembly)

  • Copy DWP file to C:\Inetpub\wwwroot\wpcatalog

  • Copy resources to
    - For GAC-registered parts, C:\Program Files\Common Files\Microsoft Shared\web server extensions\wpresources
    - For Web Parts in the /bin directory, C:\Inetpub\wwwroot\wpresources

  • Adjust web.config
    - Register as SafeControl
    - Select Code Access Security settings


Method 2: CAB File

  • CAB file should contain
    -Assembly DLL
    -DWP file(s)
    -Manifest.XML
    -Resource files (if needed)
  • CAB won't contain
    - Code Access Security settings

  • Server-side object model has methods for deploying such a CAB file

  • Deploy with STSADM.EXE
    Located in C:\Program Files\Common Files\Microsoft Shared\web server extensions0\BIN
    Add it to your path
    Stsadm -o addwppack -filename filename [-globalinstall] [-force]

New Version of the Caml Query Builder Tool

New version of her CAML Query Builder Tool! Version 3.1.0.0 has some great new features:
  • Query fields by ID
  • GetListItemChanges (method of the Lists.asmx web service)
  • GetListItemChangesSinceToken (method of the Lists.asmx web service)
  • extra options of the QueryOptions part
  • support for data type ModStat
Download here and check her blog post for the full details.

Adding Breadcrumb Navigation to Application Pages in SharePoint Central Administration

Last week I have found one good articles that can useful for make breadcrumb in central administration.

http://weblogs.asp.net/jan/archive/2008/10/10/adding-breadcrumb-navigation-to-application-pages-in-sharepoint-central-administration.aspx

Current Page URL in the UrlAction of a SharePoint Feature

With the introduction of the feature framework in SharePoint 2007, developers have some great opportunities to customize and enhance nearly everything in SharePoint.

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction
Id="{6FCB0F81-2105-4d9f-96BF-C48A19B8E439}"
Title="My Link"
Location="Microsoft.SharePoint.StandardMenu"
GroupId="SettingsMenu">
<UrlAction Url="_layouts/mypage.aspx"/>
</CustomAction>
</Elements>

When activated, the feature will add a menu item to the Settings menu of any SharePoint list or document library. The menu item will have the title My Link, when clicked the user will navigate to the page mypage.aspx in the _layouts folder

<UrlAction Url="_layouts/mypage.aspx?listid={ListId}"/>

The {ListId} URL token will be automatically replaced with the ID of the list, in which the menu item is shown. In the mypage.aspx, you can retrieve the value of the listid parameter by making use of the QueryString. Once you've got the ID, the object model can be used to get a reference to the SPList instance of that list. According to the documentation on MSDN, the following URL tokens can be used:

  • ~site - Web site (SPWeb) relative link.
  • ~sitecollection - site collection (SPSite) relative link.
  • In addition, you can use the following tokens within a URL:
    • {ItemId} - Integer ID that represents the item within a list.
    • {ItemUrl} - URL of the item being acted upon. Only work for documents in libraries. [Not functional in Beta 2]
    • {ListId} - GUID that represents the list.
    • {SiteUrl} - URL of the Web site (SPWeb).
    • {RecurrenceId} - Recurrence index. This token is not supported for use in the context menus of list items.

Thursday, November 20, 2008

Enabling anonymous access in SharePoint 2007

First, you need to enable anonymous on the IIS web site (called a Web Application in SharePoint land). This can be done by:

  • Launching Internet Information Services Manager from the Start -> Administration Tools menu
  • Select the web site, right click and select Properties
  • Click on the Directory Security tab
  • Click on Edit in the Authentication and access control section

Instead we’ll do it SharePoint style using the Central Administration section:

  • First get to your portal. Then under “My Links” look for “Central Administration” and select it.
  • In the Central Administration site select “Application Management” either in the Quick Launch or across the top tabs
  • Select “Authentication Providers” in the “Application Security” section
  • Click on the “Default” zone (or whatever zone you want to enable anonymous access for)
  • Under “Anonymous Access” click the check box to enable it and click “Save”

NOTE: Make sure the “Web Application” in the menu at the top right is your portal/site and not the admin site.

You can confirm that anonymous access is enabled by going back into the IIS console and checking the Directory Security properties.

Now the second part is to enable anonymous access in the site.

  • Return to your sites home page and navigate to the site settings page. In MOSS, this is under Site ActionsSite SettingsModify All Site Settings. In WSS it’s under Site ActionsSite Settings.
  • Under the “Users and Permissions” section click on “Advanced permissions”
  • On the “Settings” drop down menu (on the toolbar) select “Anonymous Access”
  • Select the option you want anonymous users to have (full access or documents and lists only)

Now users without logging in will get whatever option you allowed them.

A couple of notes about anonymous access:

  • You will need to set up the 2nd part for all sites unless you have permission inheritance turned on
  • If you don’t see the “Anonymous Access” menu option in the “Settings” menu, it might not be turned on in Central Admin/IIS. You can manually navigate to “_layouts/setanon.aspx” if you want, but the options will be grayed out if it hasn’t been enabled in IIS
  • You must do both setups to enable anonymous access for users, one in IIS and the other in each site

MOSS Architecture: Model, SSP, Portal

MOSS adopts a 3-tier model with:

1. Web servers at the front: web servers which can be network balanced to achieve addl performance and fault tolerance
2. Application servers in the middle: servers collection that provide shared services to portals and sites (SSP)
3. Database servers at the back where data and config is stored and can be clustered

The prominent services provided by the Application Servers include:
  • Search
  • Index
  • Audience compilation
  • User profiles database
  • My Sites
  • Business Data Catalogue
  • Excel Services
Any of the above services can exist on any number of servers within the SSP.

Portal:

It is now called "Collaboration Portal", not "Portal" as in earlier version of SharePoint and it is just another site collection that is hosted on a IIS site(Web Application).Portals don't contain any application services such as Search, My Site etc. Now, everything has to come thru SSP. This means that we just need a web server to host a portal and a place to include the content database.

Different portals can live on their own hardware completely isolated from any other hardware other than the fact that it consumes services from a centrally managed SSP. Alternatively, you can put some of your portals on shared hardware and some on dedicated.

All three tiers (web, application, database) of the SharePoint model can be hosted on a single machine or scaled out to a huge collection of servers to meet the requirements.

Most organisations will want some level of fault tolerance and separation between server roles.

Medium-Farm Configuration:

Typically these kind of organisations will have at least 2 web servers running your portals and sites, at least one application server hosting all services (maybe a second for fault tolerance) and one database cluster.

Large-Farm Configuration:

Larger organisations may want to have separate web servers for each of their portals, sites and my sites. They may also go for multiple application servers as part of the SSP.

Tables within MOSS 2007

  • AllDocs: holds information about all the documents (and all list items) for each document library and list
  • AllLists: holds information about lists for each site
  • AlllistData: holds information about all the list items for each list
  • AllUserData: holds all the metadata which user provides in a document library
  • GroupMembership: holds information about all the SharePoint group members
  • Groups: holds information about all the SharePoint groups within each site collection
  • ImmedSubscriptions: holds information about all the immediate subscriptions (alerts) for each user
  • RoleAssignment: holds information about all the users or SharePoint groups that are assigned to roles
  • Roles: holds information about all the SharePoint roles or permission levels for each site
  • SchedSubscriptions: holds information about all the scheduled subscriptions (alerts) for each user
  • Sites: holds information about all the site collections relevant to this content database
  • UserInfo: holds information about all the users within each site collection
  • Webs: holds information about all the specific sites (webs) in each site collection

Understanding RunWithElevatedPrivileges

What happens when you use RunWithElevatedPrivileges ?

Without RunWithElevatedPrivileges delegate the Sharepoint identity will be the same as of the current user identity and you are able to do whatever your own permissions allow you to do.

With RunWithElevatedPrivilages delegate the Sharepoint set the identity to Sharepoint\System. The Sharepoint\System identity doesn't have anything to do with a windows identity so you shouldn't be tempted to look for this windows account. The Sharepoint\Sytem is a built-in identity of Sharepoint and it has full permissions in Sharepoint. Also RunWithElevatedPrivilages elevates the windows privilages which means that if you are running the elevated code from a web application the applicaion is basically using the identity of the account running the webApp pool.

Incase of winforms/console application, code runs with your credentials (or if using 'runas', it would use whatever credentials you told it to use). There is no impersonation going on here like with the web application, so a call a to RunWithElevatedPrivileges will effectively do nothing because there is no impersonation to temporarily halt. You can see this is the case if you were to execute this code snippet in a console application:

SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite(siteUrl))
{
using (SPWeb web = site.OpenWeb(webUrl))
{
System.Console.WriteLine(web.CurrentUser.LoginName);
System.Console.WriteLine(System.Security.Principal.WindowsIdentity.GetCurrent().Name);
System.Console.ReadKey();
}
}
});


Note here that web.CurrentUser.LoginName is coming from the WSS identity. If you 'runas' the web application's app pool identity, it would get correlated to SharePoint\System and thats what you would see on the first line of output.

Wednesday, November 19, 2008

Hide Quick Launch using CSS

Add content editor webpart and insert this css in it.

<style>
.ms-navframe
{
display:none;
}
</style>

Monday, November 17, 2008

The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again.

The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Runtime.InteropServices.COMException: The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:

[COMException (0x8102006d): The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again.]
Microsoft.SharePoint.Library.SPRequestInternalClass.UpdateRoleAssignment(String bstrUrl, Guid& pguidScopeId, Int32 lPrincipalID, Object& pvarArrIdRolesToAdd, Object& pvarArrIdRolesToRemove) +0
Microsoft.SharePoint.Library.SPRequest.UpdateRoleAssignment(String bstrUrl, Guid& pguidScopeId, Int32 lPrincipalID, Object& pvarArrIdRolesToAdd, Object& pvarArrIdRolesToRemove) +119
[SPException: The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again.]
OfficialMail.WebParts.TestWebPart.btn_Click(Object sender, EventArgs e) +94
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102

Solutions :
Central Administration > Application Management > Web Application General Settings ->Select web application

In Web Page Security Validation , change security validation is off.

Thursday, November 6, 2008

some useful links....

Go through this link that have more useful sharepoint tutorials link that useful for sharepoint developer.

http://sharepoint-exchange.blogspot.com/2008_02_01_archive.html

MOSS 2007 User and Profiles import from Active Directory


Its very normal to have a scenario in which the user profile information in stored in directory service like Active Directory. Since personalization in sharepoint largely depends upon user profiles it becomes imperative to not only import the user information in AD into sharepoint as user profiles but also to run incremental imports to sync up user profiles with new information added into the Active directory.

As you know sharepoint integrates with Active directory and a user profile record gets created in sharepoint when an AD authenticated user first accesses a site. Assumption here is that the user already has adequate permissions on the site. As noted above incremental imports facilitate synchronizing user information stored in AD with the profile created in sharepoint.

The following steps need to be followed to configure import of user profiles from Active Directory -

Scenario-1 - All users are in the current domain.


1. Go to User Profile and Properties under Shared Services Administration.

2. Click on configure profile import link. Select current domain as the profile datasource.

3. Make sure default access account is specified and is valid.

4. Run full import or incremental report.


Scenario-2 - Users are scattered into multiple domains or other data sources.


1. Go to User Profile and Properties under shared services administration.

2. Click on Import New Connection. Add a new connection for each of the data sources where you users are located. Delete any unwanted connections that might already be there.

3. Configure the import as mentioned above and make sure that Custom source is selected.

4. Run the full import or incremental import.