Return to doc.sitecore.com

9.  Extranet (Published Site) Authentication
Prev

When using LDAP for Extranet, Users can be authenticated using the same Sitecore code as would be used without the LDAP module:

Sitecore.SecurityModel.IDomain domain = Sitecore.Configuration.Factory.GetDomain( "extranet" );
Sitecore.SecurityModel.DomainAccessResult result = domain.Login(txtUsername.Text,txtPassword.Text );
if ( result.Success )
//...

The package adds a “ldap_ExtranetLogin” sublayout to the “/sitecore modules/web” folder for use as a login facility; configuration is described in FAQ (http://sdn.sitecore.net/sdn5/faq/api/custom%20login%20page.html).  Additionally, the “ldap_DomainExtranetLogin” sublayout provides an example of an automatic login to Extranet:

string sUser = Request.ServerVariables["LOGON_USER"];
sUser = sUser.Substring( sUser.LastIndexOf( "\\" ) + 1 );
ExtranetDirectLogin exLogin = new ExtranetDirectLogin();
DomainAccessResult result = exLogin.Login( sUser );
if( result.Success )
//...

If Request.ServerVariables["LOGON_USER"] returns null, anonymous access has not been properly disabled in IIS (see Completion section under Configuration).


Prev