Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
So far we've seen how to make use of the new ASP.NET 2.0 login controls by creating an MCMS Membership Provider for Windows accounts and using it with Forms Authentication. It is also possible to use the same approach to provide a more elegant solution for "account mapping" scenarios whereby authentication takes place against an external user store.
For example, suppose we needed to use Active Directory Application Mode (ADAM) for authentication, we could implement an ADAM Membership Provider based upon our MCMSMembershipProviderBase class by overriding the ValidateUser()method:
using System.DirectoryServices;
...Code Continues ...
public override bool ValidateUser(string strName, string strPassword)
{
// the LDAP server to connect to
string strLdapServer = "LDAP://localhost:389/";
// the DN of the OU containing the user
string strLdapObj = "OU=MCMSUsers,O=TropicalGreen";
// the DirectoryEntry property to validate
string strDECheck = "MCMSUsers";
// the DN of the user we are connecting as
string strBindName = "CN=" + strName + "," + strLdapObj;
// the Windows Username format for pasing to ValidateUser
string strWindowsUser = "WinNT://webdev/" + strName;
try
{
// Connect to ADAM using LDAP AuthN...
DirectoryEntry ent = new DirectoryEntry(strLdapServer +
strLdapObj, strBindName,
strPassword, AuthenticationTypes.None....