Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Customize a SharePoint Login Page : Page 4

Go beyond the complexities of working with SharePoint, and discover how to create a custom login page that you can associate with unique code.


advertisement
Create the Login Page
The first step in creating the login page is to locate the \Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\LAYOUTS directory. From there create a new directory, for instance DEVX, and copy the simple.master and login.aspx files into that directory. After copying the files, open the login.aspx page in Visual Studio 2005. There are three things you must change in the existing login.aspx file for your code-behind to work.

The first change is in the @Page tag, or more specifically the Inherits attribute. This attribute needs to reflect the full class name and assembly of the class library you created previously. The second change is in MasterPageFile, which needs to include the subdirectory you just added to the simple.master file. Note that this step isn't technically required for the application example here because you don't customize the simple.master file, but in your deployment it's likely you'll customize the master to reflect the branding of your organization. The third change is to assign the ID loginBox—instead of login—to the ASP.NET login control. This change is necessary because there are two controls with login in their names, and in the code behind file you named the control loginBox; therefore, you must rename it in your login page to ensure they match and aren't ambiguous for the compiler.

Referencing the class you created previously is a bit more challenging because it's long. The type identifier is made up of five parts with a comma separating each part:

  • The full name of the class, which includes the namespace.
  • The name of the assembly, which is the name of the assembly file without the period and DLL extension.
  • The version number of the assembly, which should be 1.0.0.0, by default, but can be changed.
  • The culture for the assembly, which defaults to neutral but can be changed.
  • The publickeytoken for the assembly, which although technically it's not required for every deployment it is necessary for all assemblies installed in the GAC—as you're going to do with this assembly.



When you put these parts together the type name is somewhat long—for example:

CustomLoginPages.CustomLogin, CustomLoginPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e19ad244f8c54bd6

Deploy and Run
Now you're ready to deploy the code and run it. In the deployment category there are two steps: First, deploy the CustomLoginPage assembly to the web application's bin directory, or alternatively to the GAC. Second, in the web.config file modify the configuration/system.web/authentication/forms node's loginUrl attribute to point to the new location for the login.aspx page.

All that's left to do is to open a web browser to the web application and try to go to a secure page—or click the login link—to display a new login page. You'll be able to log in with your e-mail address as well as your user name. Sometimes relatively simple procedures like this one can be the difference between thousands of hours writing custom authentication providers and a handful of hours spent enhancing a page in SharePoint. Which one would you prefer?



Robert Bogue, MCSE (NT4/W2K), MCSA:Security, A+, Network+, Server+, I-Net+, IT Project+, E-Biz+, CDIA+ has contributed to more than 100 book projects and numerous other publishing projects. He was recently honored to become a Microsoft MVP for Microsoft Commerce Server and before that Microsoft Windows Servers-Networking. Robert blogs at http://www.thorprojects.com/blog.
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap