Saturday, March 27, 2010

Customising Welcome message of the site

Hi,


There may be the situation where you may have to customise the welcome message which will be on the right top of the site.For that i got the good link.Now my requirement was displaying the message based upon the intranet/extranet site.For that initially i have written the below code in welcome.ascx but the problem is it use to execute if condition always


Finally after seeing the link


http://www.wictorwilen.se/Post/Having-fun-with-the-SharePoint-Welcomeascx-control.aspx


what i did is


I took a custom user controlcustomwelcome.ascx and copy pasted the code of welcome.ascx in it and I have wriiten code in webpart as


namespace CustomWelcome {


public class Welcome : Microsoft.SharePoint.WebControls.Welcome {


protected Welcome() {


}


[SharePointPermission(SecurityAction.Demand, ObjectModel = true)]


protected override void OnLoad(EventArgs e)


{


base.OnLoad(e);


if (HttpContext.Current.User.Identity.IsAuthenticated)


{


if (HttpContext.Current.User.Identity.AuthenticationType==”Forms”)


{


PostCacheSubstitutionText pt = base.ExplicitLogout.MenuControl.Controls[0]


as PostCacheSubstitutionText;


pt.TextType = PostCacheSubstitutionTextType.UserName;


pt.SuffixHtml=”(Extranet)”


}


Else


{


PostCacheSubstitutionText pt = base.ExplicitLogout.MenuControl.Controls[0]


as PostCacheSubstitutionText;


pt.TextType = PostCacheSubstitutionTextType.UserName;


pt.SuffixHtml=”(Intranet)”


}


}


}


}


}












Thursday, March 11, 2010

Dynamic Navigation

DynamicNavigation.cs

There is a list called DocListNames.Now I shld display the items of the Title field in the form of the table.Actually the items in Title field of MBIADocListNames list are document library names of the site and based upon the Display Indicator field value Yes it has to display the document library names

For this the code is

protected override void Render(System.Web.UI.HtmlTextWriter writer)

{

SPSite objsite = SPContext.Current.Site;

SPWeb objweb = SPContext.Current.Web;

SPList objlist = objweb.Lists["DocListNames"];

string camlquery = " Yes";

SPQuery query = new SPQuery();

query.Query = camlquery;

SPListItemCollection listItemCollection = objlist.GetItems(query);

if (listItemCollection.Count > 0)

{

writer.Write("

");

writer.Write("

");

foreach (SPListItem itmlist in listItemCollection)

{

string title = (itmlist["Title"]).ToString();

writer.Write("

");

}

writer.Write("

");

writer.Write("

");

writer.Write("&nbsp");

writer.Write("");

writer.Write(title);

writer.Write("");

writer.Write("&nbsp");

writer.Write("

");

}

}

Saturday, March 6, 2010

Form Based Authentication in WSS/MOSS 2007

Create Database using-C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727

Create a asp.net site and add new item web.config- add the below entry For Extranet and for Internet sites

Use asp.net web site administration tool to add user

Extend the web site for Internet - set proper setting

======================================

For Extranet and for Internet sites

====================

connectionString="server=servername;database=databasename;Integrated Security=SSPI;"

providerName="System.Data.SqlClient"/>

====================

In Central Admin

type="System.Web.Security.SqlMembershipProvider, System.Web,Version=2.0.0.0, Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a"

connectionStringName="AcSqlConnString"

enablePasswordRetrieval="false"

enablePasswordReset="true"

requiresQuestionAndAnswer="false"

applicationName="/"

requiresUniqueEmail="false"

passwordFormat="Hashed"

maxInvalidPasswordAttempts="5"

minRequiredPasswordLength="1"

minRequiredNonalphanumericCharacters="0"

passwordAttemptWindow="10"

passwordStrengthRegularExpression=""

/>

type="System.Web.Security.SqlRoleProvider, System.Web,Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"

connectionStringName="AcSqlConnString"

applicationName="/"

/>

==========================

Now add the users to parent sites

==============================

Start testing the extended sites.

==================================

Best of luck