F5 Sites
  • F5.com
  • LearnF5
  • NGINX
  • MyF5
  • Partner Central
Contact
  • Under Attack?
  • F5 Support
  • DevCentral Support
  • F5 Sales
  • NGINX Sales
  • F5 Professional Services
Skip to contentBrand Logo
Forums
CrowdSRC
Articles
Groups
EventsSuggestionsHow Do I...?
RegisterSign In
  1. DevCentral
  2. Articles
  3. Technical Articles

Configuring APM Client Side NTLM Authentication

Introduction There have been a ton of requests on the boards for a simplified client side NTLM configuration, so based on Michael Koyfman’s excellent Leveraging BIG-IP APM for seamless client NTLM...
Published May 12, 2015
Version 1.0
authentication
BIG-IP Access Policy Manager (APM)
ntlm
security
Kevin_Stewart's avatar
Kevin_Stewart
Icon for Employee rankEmployee
Joined March 16, 2006
View Profile
Kevin_Stewart's avatar
Kevin_Stewart
Icon for Employee rankEmployee
Joined March 16, 2006
View Profile
Kevin_Stewart's avatar
Kevin_Stewart
Icon for Employee rankEmployee
Jan 02, 2018

After some additional testing, I believe that a Windows Registry check would require something closer to what Michael Koyfman has described. So for clarity, it basically boils down to something like this:

Simplified iRule:

when RULE_INIT {
    set static::ntlm_config "/Common/F5NTLM"
}
when ACCESS_SESSION_STARTED {
    ACCESS::session data set "session.ntlm.last.retries" 0
}
when HTTP_REQUEST {
    switch -glob -- [string tolower [HTTP::uri]] {
        "/ntlm/auth" {
            if { [HTTP::cookie value MRHSession] ne ""  } {
                set sid [HTTP::cookie value MRHSession]
            }
            catch { 
                set sid [ACCESS::session sid]
            }
            set referer [HTTP::header value Referer]
            set x_session_id [HTTP::header value X-Session-Id]
            if { [string length $x_session_id] != 0 } {
                set sid $x_session_id
            }
            set retries [ACCESS::session data get -sid $sid "session.ntlm.last.retries"]
            set auth_result [ACCESS::session data get -sid $sid "session.ntlm.last.result"]
            if { ($auth_result == 1) || (($retries == 2) && ($auth_result != 1)) } {
                ECA::disable
                HTTP::redirect $referer
            } else {
                ECA::enable
                ECA::select select_ntlm:$static::ntlm_config
            }
            unset x_session_id
            unset referer
        }
        default {
            ECA::disable
        }
    }
}
when ECA_REQUEST_ALLOWED {
    ACCESS::session data set session.ntlm.last.username "[ECA::username]"
    ACCESS::session data set session.ntlm.last.domainname "[ECA::domainname]"
    ACCESS::session data set session.ntlm.last.machinename "[ECA::client_machine_name]"
    ACCESS::session data set session.ntlm.last.status "[ECA::status]"
    ACCESS::session data set session.ntlm.last.result 1
    ACCESS::disable
    HTTP::header insert X-Session-Id $sid

    use virtual [ virtual name ]
}

The set of ACCESS::session set commands in the ECA_REQUEST_ALLOWED event are not expressly required, but useful if you need to access NTLM user information from elsewhere. So basically, once the Windows Registry check determines this is a domain client, control is passed to an external logon page that redirects to itself at the /ntlm/auth URI. The HTTP_REQUEST event in the iRule is triggered and enables/disables ECA based on where you are in the policy evaluation. Once NTLM/ECA succeeds, the ECA_ALLOWED_REQUEST event disables access evaluation and injects the X-Session-ID header.

It's worth noting that if you simply performed an IP subnet check in an iRule, you wouldn't need to do all of this.

ABOUT DEVCENTRAL

DevCentral NewsTechnical ForumTechnical ArticlesTechnical CrowdSRCCommunity GuidelinesDevCentral EULAGet a Developer Lab LicenseBecome a DevCentral MVP

RESOURCES

Product DocumentationWhite PapersGlossaryCustomer StoriesWebinarsFree Online CoursesF5 CertificationLearnF5 Training

SUPPORT

Manage SubscriptionsProfessional ServicesProfessional ServicesCreate a Service RequestSoftware DownloadsSupport Portal

PARTNERS

Find a Reseller PartnerTechnology AlliancesBecome an F5 PartnerLogin to Partner Central

F5 logo©2024 F5, Inc. All rights reserved.
TrademarksPoliciesPrivacyCalifornia PrivacyDo Not Sell My Personal Information