Saturday, August 30, 2008

CSS Reference Chart for SharePoint 2007

Here is the CSS reference link that can be used in the Moss 2007 and WSS 3.0.

The default CSS files are located on the web server in the following directory: Local Drive:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\1033\STYLES.


Additional styles are located in the Publishing feature: Local Drive:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\PublishingLayouts\en-us

http://www.heathersolomon.com/content/sp07cssreference.htm

Friday, August 29, 2008

SP Installer Batch File

Here is the sharepoint installer batch file that you can copy Master page,Application page, create new folder , generate new site using command line and store the site using command line.

echo Copying the feature...

:: Copy Master File

copy /Y simple1.master "%CommonProgramFiles%\Microsoft Shared\web server extensions\12\Template\Layouts\"

:: Copy aspx file

copy /Y LoginUser.aspx "%CommonProgramFiles%\Microsoft Shared\web server extensions\12\Template\Layouts\"

:: Make Folder for the UserControl

mkdir "%CommonProgramFiles%\Microsoft Shared\web server extensions\12\Template\Layouts\UserControl"

:: Copy the UserControl into the UserCOntrol Folder

copy /Y RecoverPassword.ascx "%CommonProgramFiles%\Microsoft Shared\web server extensions\12\Template\Layouts\UserControl\"

:: Copy Images and Css

copy /Y *.gif "%CommonProgramFiles%\Microsoft Shared\web server extensions\12\Template\Layouts\1033\Images\"

copy /Y *.css "%CommonProgramFiles%\Microsoft Shared\web server extensions\12\Template\Layouts\1033\styles\"

echo Activating the feature...

pushd %programfiles%\common files\microsoft shared\web server extensions\12\bin

:: Create New Site using Command Line

stsadm -o extendvs -url "http://sps:16333" -ownerlogin "serverpsp\trushar" -owneremail "trushar@sps.com" -dn "SP_test" -apcreatenew -apidname "TEST1" -apidtype configurableid -apidlogin "serverpsp\trushar" -apidpwd "trushar"

:: Copy WebConfig,DLL,Pages

copy /Y *.dll "%inetpub%\Inetpub\wwwroot\wss\VirtualDirectories\16333\bin\"

copy /Y web.config "%inetpub%\Inetpub\wwwroot\wss\VirtualDirectories\16333\"

mkdir "%inetpub%\Inetpub\wwwroot\wss\VirtualDirectories\16333\UserControl"

copy /Y myacc.ascx "%inetpub%\Inetpub\wwwroot\wss\VirtualDirectories\16333\UserControl\"

:: Restore New Site

stsadm -o restore -url "http:// sps:16333" -filename "C:\TestBKP.dat" -overwrite

Thursday, August 28, 2008

Form Authentication in sharepoint server 2007

Step 1: Configure SharePoint Site Web.config

You should be tired of messing with configuration settings, but the end is near. Go ahead and open the Web.config in the root directory of your SharePoint site. When you are finished, you need to set the defaultProvider attributes in the as shown in Listing below.
<membership defaultProvider="ADProvider">
<providers>
<!--Need to configure the values of the connectionUserName and connection Password.-->
<add name="ADProvider" type="System.Web.Security.ActiveDirectoryMembershipProvider,System.Web, Version=2.0.0.0, Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="ADConnString" connectionUsername="administrator" connectionPassword="Pss_2inf" attributeMapUsername="sAMAccountName" connectionProtection="None"/>
</providers>
</membership>
<identity impersonate="true"/>

<authentication mode="Forms">
<!-- Detailed Configuration Options -->
<forms loginUrl="SignUpLoginUser.aspx" timeout="30" slidingExpiration="true" cookieless="AutoDetect" protection="All" requireSSL="false" defaultUrl="Default.aspx"/>
</authentication>
<location path="Default.aspx">
<system.web>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</location>

Step 2: Enable Forms Authentication on the SharePoint site

You enable Forms Authentication for SharePoint sites using SharePoint Central Administration. Navigate to the Central Admin site using your browser. You can normally find a shortcut to the site in the Start menu:


Programs > Office Server 2007 > SharePoint 3.0 Central Administration


When working in SharePoint Central Administration website, make sure the correct Web Application is selected when you are about to change configuration settings; otherwise you'll be applying changes to the wrong site. There's a small light-blue bar in the content pane of the page that displays the current Web Application URL. Make sure it's the web application on which you want to enable Forms authentication. If it's not, click the little down-arrow next to the URL and choose "Change Web Application" from the drop down list. SharePoint then displays a popup window with a list of web application from which you may choose.

Once you have the right web application selected, the Authentication Providers page displays a list of the zones in that application. Click on the name of the zone in which you want to enable Forms authentication. The Edit Authentication page displays


In the Edit Authentication page, choose the "Forms" option for Authentication Type. The page refreshes and displays the Membership provider and Role manager sections. Enter ADProvider in the Membership provider name textbox, and ADProvider in the Role manager name textbox, then click the Save button. You are taken back to the Authentication Providers screen, but your zone should now say ADProvider under the Membership Provider Name column. Forms authentication is now enabled on the site.

Step 3: Authenticate the Forms-based user to access the site

Now that Forms authentication is enabled on the site, you can hit the site and see the login form Microsoft spared no expense making this the blandest form you'll ever see. You will probably want to customize it so it looks a lot nicer. Maybe include some text about how the user should enter their username and password. Nobody will read it, but it definitely makes a login form look like a login form. Anyway, if you enter your username and password, you will be successfully authenticated and then promptly denied access because you have no authorization to be in the site. So, how do you get authorization? You have to use the Site Collection Administrator account.

You may remember setting up a Site Collection Administrator when you first created the site a while back, and it was almost certainly a Windows user account. If you extended the site and have both a Windows zone and a Forms authentication zone, then you can login to the Windows zone and setup the Forms user in Site Settings as you would any other user.

If you have not extended the site, then you've only got one zone and its using Forms authentication. As such, the Windows account associated with the site collection administrator is effectively useless and you need to change the site collection administrator over to a Forms based account. To do this, open SharePoint Central Administration and click on the Application Management link in the left navigation menu. When the Application Management page displays, click the Site Collection Administrators link under the SharePoint Site Management section in the left-hand column of the page.



On the Site Collection Administrators page, make sure that correct site collection is selected. Then, enter the username of the user you created back in the Primary Site Collection Administrator textbox. Click on the Check Names icon (the little red guy with a check mark) next to the textbox. It may take a few seconds, but the page should underline the text in the textbox indicating that the username is valid. If the username is not valid, the page puts a red squiggly line under the username and informs you that the user was not found. If the user is not found, make sure you typed the name correctly. If the issue persists, go back and check your configuration settings to ensure the connection string is valid and there are no typos.

Click on the OK button to save the changes. Your Forms authentication account is now a Site Collection Administrator who has authorization to visit the site. You can use that account to get into the site and setup additional Forms authentication users in Site Settings.Step 4: Login When you access the site, you are presented with the previously-mentioned default SharePoint login page . Enter your username and password, and then click the Sign In button. You should be authenticated and authorized, and the site should display as you would expect.



STSADM Command for sharepoint list,feature and webpart

Wednesday, August 27, 2008

Distinct Values After Execute SP CAML Query

using (SPSite site = new SPSite(ConfigurationManager.AppSettings["SiteUrlPath"]))
{
using (SPWeb web = site.OpenWeb())
{
SPList lst = web.Lists["test"];
DataTable dt = lst.Items.GetDataTable();
if (dt != null && dt.Rows.Count > 0)
{
DataView v = new DataView(dt);
DataTable dtview = v.ToTable(true, "test");

}

}
}