Saturday, March 19, 2011

Add password reset page in Form Based Authentication MOSS 2007 site

Add password reset page in Form Based Authentication MOSS 2007 site:

Overview:

This article explains how to add a reset password page in Form Based Authentication enable SharePoint 2007 (MOSS) site, so the user can reset his/her password. We will add this page in standard menu.

Problem:

When you enable forms authentication on SharePoint 2007 (MOSS), it means that users credentials are stored in membership database like ASP.NET database. In Form Based Authentication site, if we want to reset password then reset password page should be accessible to anonymous user also.

Solution:

We are going to add new feature (ResetPasswordPage feature) in the standard user menu:

1. Write code .cs file(c# file), In this class, we will inherit the class Microsoft.SharePoint.WebControls.UnsecuredLayoutsPageBase

For example:

public class ExtranetPasswordReset_Test : Microsoft.SharePoint.WebControls.UnsecuredLayoutsPageBase


2. Creating ExtranetPasswordReset_Test.aspx
3. Creating ResetPasswordPage feature
4. Deployment

1. Creation of ExtranetPasswordReset_Test.aspx:

We will create new ExtranetPasswordReset.aspx with the help of VS 2005.

<%@ Assembly Name="Microsoft.SharePoint,Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Page Language="C#" Inherits="Microsoft.SharePoint.WebControls.UnsecuredLayoutsPageBase" MasterPageFile="~/_layouts/simple.master" %>
<%@ Assembly Name="Test.Security, Version=3.0.0.0, Culture=neutral, PublicKeyToken=8b7a42e9b9b5355f" %>
<%@ Register TagPrefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Import Namespace="Microsoft.SharePoint.ApplicationPages" %>



Site Title:




Code behind file of ExtranetPasswordReset_Test.aspx, called ExtranetPasswordReset_Test.aspx.cs:

1. We need add two functions:
I. protected override bool AllowAnonymousAccess
II. protected void Page_Load(object sender, EventArgs e)






2. Inherit the class with UnsecuredLayoutsPageBase class.







namespace Test.Security.Web.UI
{


public class ExtranetPasswordReset_Test : Microsoft.SharePoint.WebControls.UnsecuredLayoutsPageBase
{
protected override bool AllowAnonymousAccess
{
get
{
return true;

}
}
protected void Page_Load(object sender, EventArgs e)
{
Response.Write("Test");
}


}
}









2. Create ResetPasswordPage feature:

We will create Feature file and put into the ResetPasswordPage folder inside the Feature folder.










We also need to create elements.xml file.










Set CustomAction properties as shown, Location to be ‘StandardMenu’ and UrlAction URL property should be “_layouts/ExtranetPasswordReset_Test.aspx”
3. Deployment
1. Copy ‘ExtranetPasswordReset_Test.aspx’ file to the following path:
C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\
2. Copy ResetPasswordPage folder that contains elements.xml and feature.xml to the following path: C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\

3. run the following command:










Now the feature is installed successfully, but needs to be activated.

4. Go to your site-> Site Actions -> Site Settings -> Modify All Site Settings->Site Collection Features ->Activate ResetPasswordPage feature.

Now you can find Reset Password action in the standard user menu

Share:

Monday, March 07, 2011

How to deploy DLL’s into GAC using batch (.bat) file

How to deploy DLL’s into GAC using batch (.bat) file:

Global Assembly Cache Tool (Gacutil.exe):
The Global Assembly Cache tool allows you to view and manipulate the contents of the global assembly cache and download cache.




gacutil [options] [assemblyName assemblyPath assemblyListFile]

The Gacutil is a tool used by developers to install versioned assemblies into the system Global Assembly Cache (GAC) to become part of the assemblies that are available for all applications at runtime.

Parameter:

assemblyName:The name of an assembly. You can supply either a partially specified assembly name such as myAssembly or a fully specified assembly name such as myAssembly, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0038abc9deabfle5.

assemblyPath:The name of a file that contains an assembly manifest.

assemblyListFile:The path to an ANSI text file that lists assemblies to install or uninstall. To use a text file to install assemblies, specify the path to each assembly on a separate line in the file. The tool interprets relative paths, relative to the location of the assemblyListFile. To use a text file to uninstall assemblies, specify the fully qualified assembly name for each assembly on a separate line in the file. See the assemblyListFile contents examples later in this topic.


Option:

/cdl :Deletes the contents of the download cache.

/f :Specify this option with the /i or /il options to force an assembly to reinstall. If an assembly with the same name already exists in the global assembly cache, the tool overwrites it.

/h[elp] :Displays command syntax and options for the tool.

/i assemblyPath :Installs an assembly into the global assembly cache.

/if assemblyPath :Installs an assembly into the global assembly cache. If an assembly with the same name already exists in the global assembly cache, the tool overwrites it.
Specifying this option is equivalent to specifying the /i and /f options together.

/il assemblyListFile :Installs one or more assemblies specified in assemblyListFile into the global assembly cache.

/ir assemblyPath :Installs an assembly into the global assembly cache and adds a reference to count the assembly. You must specify the assemblyPath, scheme, id, and description parameters with this option. For a description of the valid values you can specify for these parameters, see the /r option. Specifying this option is equivalent to specifying the /i and /r options together.

/l [assemblyName] :Lists the contents of the global assembly cache. If you specify the assemblyName parameter, the tool lists only the assemblies matching that name.

/ldl :Lists the contents of the downloaded files cache.

/lr [assemblyName] :Lists all assemblies and their corresponding reference counts. If you specify the assemblyName parameter, the tool lists only the assemblies matching that name and their corresponding reference counts.

/nologo :Suppresses the Microsoft startup banner display.

/r [assemblyName assemblyPath] :Specifies a traced reference to an assembly or assemblies to install or uninstall. Specify this option with the /i, /il, /u, or /ul options.
To install an assembly, specify the assemblyPath, scheme, id, and description parameters with this option. To uninstall an assembly, specify the assemblyName, scheme, id, and description parameters.
To remove a reference to an assembly, you must specify the same scheme, id, and description parameters that were specified with the /i and /r (or /ir) options when the assembly was installed. If you are uninstalling an assembly, the tool also removes the assembly from the global assembly cache if it is the last reference to remove and if Windows Installer has no outstanding references to the assembly.

/silent :Suppresses the display of all output.

/u assemblyName :Uninstalls an assembly from the global assembly cache.

/uf assemblyName :Forces a specified assembly to uninstall by removing all references to the assembly. Specifying this option is equivalent to specifying the /u and /f options together.
Note :You cannot use this option to remove an assembly that was installed using Microsoft Windows Installer. If you attempt this operation, the tool displays an error message.

/ul assemblyListFile :Uninstalls one or more assemblies specified in assemblyListFile from the global assembly cache.

/u[ngen] assemblyName :Uninstalls a specified assembly from the global assembly cache. If the specified assembly has existing reference counts, the tool displays the reference counts and does not remove the assembly from the global assembly cache.
Note: In the .NET Framework version 2.0, /ungen is not supported. Instead, use the uninstall command of the Native Image Generator (Ngen.exe).
In the .NET Framework versions 1.0 and 1.1, specifying /ungen causes Gacutil.exe to remove the assembly from the native image cache. This cache stores the native images for assemblies that have been created using the Native Image Generator (Ngen.exe).

/ur assemblyName :Uninstalls a reference to a specified assembly from the global assembly cache. To remove a reference to an assembly, you must specify the same scheme, id, and description parameters that were specified with the /i and /r (or /ir) options when the assembly was installed. For a description of the valid values you can specify for these parameters, see the /r option. Specifying this option is equivalent to specifying the /u and /r options together.

/? :Displays command syntax and options for the tool.


Problem: How to deploy DLL’s into GAC using batch (.bat) file
Resolution:
There are 2 ways to deploy DLL’s into GAC using batch (.bat) file:
1. Using ul & il option of Gacutil.exe in batch file:
For example, we need to un-install some Microsoft.Practices.EnterpriseLibrary.Common,Version=3.1.0.0 dll from GAC and need to install some Microsoft.Practices.EnterpriseLibrary.Common,Version= 5.0.414.0 into GAC. For this I created a text files which contain the details of DLL’s which we need to un-install and install:

i. UnInstallAssemblyList.txt:


Microsoft.Practices.EnterpriseLibrary.Common,Version=3.1.0.0,Culture=Neutral,PublicKeyToken=b03f5f7f11d50a3a
Microsoft.Practices.EnterpriseLibrary.Data,Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
Microsoft.Practices.EnterpriseLibrary.ExceptionHandling,Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging,Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging,Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
Microsoft.Practices.EnterpriseLibrary.Security.Cryptography,Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a



ii. InstallAssemblyList.txt:


Microsoft.Practices.EnterpriseLibrary.Common,Version=5.0.414.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
Microsoft.Practices.EnterpriseLibrary.Data,Version=5.0.414.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
Microsoft.Practices.EnterpriseLibrary.ExceptionHandling,Version=5.0.414.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging,Version=5.0.414.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
Microsoft.Practices.EnterpriseLibrary.Logging,Version=5.0.414.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
Microsoft.Practices.EnterpriseLibrary.Security.Cryptography,Version=5.0.414.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a



iii. InstallMicrosoftEnterpriseLibrary.bat:



@echo off
setlocal
Echo Un-Installing dll from GAC
%GACUTIL% /ul UnInstallAssemblyList.txt
Echo Installing dll in GAC
%GACUTIL% /il InstallAssemblyList.txt



For running InstallMicrosoftEnterpriseLibrary.bat:
Set the environment variables for
1. GACUTIL
Navigate to folder where InstallMicrosoftEnterpriseLibrary.bat stored and execute the following scripts:

1. InstallMicrosoftEnterpriseLibrary.bat

2. Using uf & i option of Gacutil.exe in batch file:

For example, we need to un-install some Microsoft.Practices.EnterpriseLibrary.Common,Version=3.1.0.0 dll from GAC and need to install some Microsoft.Practices.EnterpriseLibrary.Common,Version= 5.0.414.0 into GAC. For this I created a batch file called InstallMicrosoftEnterpriseLibrary.bat:



@echo off
setlocal
Echo Un-Installing dll from GAC
%GACUTIL% /uf "Microsoft.Practices.EnterpriseLibrary.Common,Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
%GACUTIL% /uf "Microsoft.Practices.EnterpriseLibrary.Data,Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
%GACUTIL% /uf "Microsoft.Practices.EnterpriseLibrary.ExceptionHandling,Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
%GACUTIL% /uf "Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging,Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
%GACUTIL% /uf "Microsoft.Practices.EnterpriseLibrary.Logging,Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
%GACUTIL% /uf "Microsoft.Practices.EnterpriseLibrary.Security.Cryptography,Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"

Echo Installing dll in GAC
%GACUTIL% /i "Microsoft.Practices.EnterpriseLibrary.Common.dll"
%GACUTIL% /i "Microsoft.Practices.EnterpriseLibrary.Data.dll"
%GACUTIL% /i "Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.dll"
%GACUTIL% /i "Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.dll"
%GACUTIL% /i "Microsoft.Practices.EnterpriseLibrary.Logging.dll"
%GACUTIL% /i "Microsoft.Practices.EnterpriseLibrary.Security.Cryptography.dll"

For running InstallMicrosoftEnterpriseLibrary.bat:
Set the environment variables for
1. GACUTIL
Navigate to folder where InstallMicrosoftEnterpriseLibrary.bat stored and execute the following scripts:
1. InstallMicrosoftEnterpriseLibrary.bat


Reference: MSDN
Share:

Sitecore® Technology MVP 2019

Featured Post

Sitecore-Front-end performance tuning points

In the previous Sitecore Performance Tuning article, i tried to explain about that Sitecore website performance depends upon Front-end ...

Total Pageviews

State Counter

Popular

About Me

My photo
Based in Bangalore, INDIA, Amit is a Sitecore MVP and MCC. He has an MCA from the U.P.T.U., INDIA and holds certifications including Sitecore and SharePoint 2007/2010. He is an contributor to Sitecore/MSDN communities and http://amitkumarmca04.blogspot.com/. Amit have experience in Sitecore, ASP.Net with C#, MVC, SharePoint, Classic ASP, VB,Macros,HTML,JavaScript,JSON,BootStrap and AngularJS.

Followers

Follow me on Twitter