Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    how connect freeradius to MS AD

    Scheduled Pinned Locked Moved Captive Portal
    32 Posts 10 Posters 17.1k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      soheil.amiri
      last edited by

      hello guys
      i setting up PFsense with freeradius package that user can authenticate via cp and connected to internet.
      now in want connect Freeradius to my MS AD environment for SSO.
      i did not find any usable tutorial for this purpose i tried to configure ldap parameter but is not working.
      how allow specific AD group access to internet via Freeradius ldap ?

      /usr/local/etc/raddb/mods-enabled/ldap
      ldap {
      	server = "192.168.192.106"
      	port = "389"
      	identity = "CN=pfsense,CN=Users,DC=mylab,DC=com"
      	password = 'Mypassword'
      	base_dn = "DC=mylab,DC=com"
      
      	user {
      		base_dn = "${..base_dn}"
      		filter = "(SAMAccountName=%{mschap:User-Name})"
      		### access_attr = "dialupAccess" ###
      	}
      	group {
      		base_dn = "${..base_dn}"
      		filter = '(objectClass=posixGroup)'
      		### name_attribute = cn ###
      		### membership_filter = "(|(&(objectClass=GroupOfNames)(member=%{control:Ldap-UserDn}))(&(objectClass=GroupOfUniqueNames)(uniquemember=%{control:Ldap-UserDn})))" ###
      		### membership_attribute = radiusGroupName ###
      		### compare_check_items = yes ###
      		### do_xlat = yes ###
      		### access_attr_used_for_allow = yes ###
      	}
      	profile {
      		filter = "(objectclass=radiusprofile)"
      		### default_profile = "cn=radprofile,ou=dialup,o=My Company Ltd,c=US" ###
      		### profile_attribute = "radiusProfileDn" ###
      	}
      
      
      1 Reply Last reply Reply Quote 0
      • S
        soheil.amiri
        last edited by

        i read Pfsense-Freeradius authentication to Active Directory, ludifrita said he could configure freeradius to authenticate by AD, how did he do ?

        1 Reply Last reply Reply Quote 0
        • S
          soheil.amiri
          last edited by

          i check and try all these post but nothing found.
          https://forum.netgate.com/topic/99075/freeradius-ldap-cannot-authenticate
          https://forum.netgate.com/topic/108441/freeradius-ldap-ad/3
          https://forum.netgate.com/topic/74052/cp-with-freeradius-and-ldap/4
          https://forum.netgate.com/topic/138307/freeradius-ldap-wpa-enterprise/5
          https://forum.netgate.com/topic/99069/freeradius-ldap-problema-na-autentica%C3%A7%C3%A3o/2

          any idea !!!!

          1 Reply Last reply Reply Quote 0
          • F
            free4 Rebel Alliance
            last edited by free4

            i will give a more complete reply this weekend but in short

            • when you connect to pfSense via SSH and you try to execute commands
            service radiusd stop (not necessarily, use this command to stop radius program if already started)
            radiusd -X (start freeradius in debug mode)
            

            what's the output ? do you have any error when starting freeradius ? when trying to authenticate an user using ldap?

            • if you have no errors when running freeradius, then that's likely a error in your LDAP filters. could you perform a packet capture of the LDAP queries/responses? does the first bind works well (I guess you disallowed anonymous binding on your AD..). does the LDAP Search query matches any results? does the final bind works correctly ?

            i am mentioning this because the error seems to come from your LDAP settings. and especially from your filters.

            • alternatively pfSense 2.4 introduced a new feature, captive portal does support authentication against multiple authentication servers now. you could configure captive portal to authenticate users both using freeradius (using the freeradius package) and using a custom LDAP servers.

            Captive portal would first check one method, if it doesn't work then it will try to authenticate users using the other one. this would mean you would configure LDAP settings directly on pfSense, instead of setting it in a pfSense Package. the advantage of doing this is that LDAP configuration in pfsense with Microsoft Active Directory is used by many users and has a clear documentation, while freeradius package doesn't (at least for the ldap part)

            in order to select against which authentication(s) server(s)/package(s) your captive portal will authenticate users, you could go to your cp settings->Authentication Servers

            S 1 Reply Last reply Reply Quote 1
            • S
              soheil.amiri
              last edited by soheil.amiri

              thanks for your reply @free4
              you are right, it's better i use pfsense LDAP option to route authentication directly to MS active directory server but how can i control users Quota ?
              captive portal have Quota option that help me to limiting users internet usage i know after exceed internet quota user will disconnected from CP, if the user try to connecting again, user will have internet access !!! did you test this scenario @free4
              to preventing users to loging again, after exceeding their internet quota i want to use freeradius.

              1 Reply Last reply Reply Quote 0
              • S
                soheil.amiri
                last edited by

                i try your command
                here is pfsense\system\general log file 0_1549039970058_ldap.PNG

                1 Reply Last reply Reply Quote 0
                • S
                  soheil.amiri @free4
                  last edited by

                  @free4 hi
                  I am waiting for your solution ?

                  1 Reply Last reply Reply Quote 0
                  • F
                    free4 Rebel Alliance
                    last edited by free4

                    @soheil-amiri Hi,

                    I have been able to reproduce your issue and i guess i found a solution. Your problem can be divided in 3 part :

                    1. First, you are currently using mschapv1/mschapv2. CHAP protocol is incompatible with the Microsoft implementation of the LDAP protocol, so you will need to use PAP instead. Unlike OpenLDAP, Microsoft AD will never disclose the password associated to an user.
                      (For the details : Freeradius can work with LDAP in two ways : "You provide me a hashed password that i will compare with the password that the LDAP server will give me" or "You provide me a cleartext password that i will submit to the AD server to check if it is valid". Only the second one is supported by Microsoft).

                    2. Appart from this CHAP issue....The main problem is strongly related to the fact that Freeradius shouldn't be on a router : When running the LDAP module, freeradius expect to be running on a computer which is part of the AD domain. This is not the case of your pfSense router, and this is what causes the timeout you are seeing in your logs.

                    more precisely, FreeRadius expect that the computer it is running on to use the Domain Controller as DNS server. FreeRadius internally perform multiple DNS request to DomainDnsZone.mylab.com and ForestDnsZones.mylab.com when using the LDAP module (for more info, please check the purpose of chase_referrals)

                    In order to use FreeRadius for your needs, you need to setup pfSense to use the DNS of your Active Directory Domain Controller. This can be done in System->General Settings page

                    0_1552255693077_5b6a8cb3-ef5d-4b47-9ad7-8838ddbae5f1-image.png

                    This will of course have strong implications, and may not be compatible with other pfSense services that you are running. It all depends how is set up your AD domain, and especially its DNS part.

                    1. Finally, it seems that there is a bug in FreeRadius 3.X, it seems to fail to correctly detect the LDAP module and returns "Authentication failed because no authentication method is available".

                    In order to overcome this problem, you can edit /usr/local/etc/raddb/sites-enabled/default manually, and add this After the redundant {} section :

                            update control { 
                                    Auth-Type := LDAP 
                            } 
                    

                    Like this :

                    0_1552260630356_cf14e7b4-74d0-4638-abc1-c4a9b3a6d3d7-image.png

                    You will need to edit this file after each update of the FreeRadius config. After each edit, you will need to execute the command "service radiusd stop && radiusd" to restart freeradius.


                    Apart from this 3 issues, the FreeRadius Package is working correctly with LDAP for me.
                    I Will post here my configuration for the record :

                    0_1552260881678_b45e41bc-585a-4cb9-9d8e-5f7003f2c8b0-image.png
                    0_1552260984680_0afb4d73-4da9-4970-bf92-d4c3216e185e-image.png

                    dragoangelD F 2 Replies Last reply Reply Quote 2
                    • S
                      soheil.amiri
                      last edited by soheil.amiri

                      dear @free4
                      thanks for your answer
                      i tried your solution
                      here is my configuration
                      NAS server (work fine)
                      1.PNG
                      Pfsense DNS configuration (work fine)
                      2.PNG
                      RADIUS config
                      5.png
                      my virtual-server configuration
                      3.png

                      but my authentication test is failed
                      system log
                      4.PNG

                      1 Reply Last reply Reply Quote 0
                      • dragoangelD
                        dragoangel @free4
                        last edited by dragoangel

                        @free4 your explenation is great, thanks! You saved part of my time. I want to add litle trick to your comment:
                        my pfSense is use Unbound transparent resolver over TLS to Cloudflare, and Windows DNS can't do TLS stuff so their upstream is pfSense, and DNS resolvers for end-clients is AD controllers. I don't want remove this flow, so I simply add to my Unbound config:

                        # Local resolving for AD domains
                        local-zone: "subdomain1.active-directory.com" transparent
                        private-domain: "subdomain1.active-directory.com"
                        local-zone: "subdomain2.active-directory.com" transparent
                        private-domain: "subdomain2.active-directory.com"
                        
                        # Forwarding
                        forward-zone:
                                name: "subdomain1.active-directory.com."
                                forward-addr: 10.1.0.10
                                forward-addr: 10.1.0.20
                                forward-addr: 2001:xxxx:xxxx:1::10
                                forward-addr: 2001:xxxx:xxxx:1::20
                                forward-first: yes
                                forward-no-cache: yes
                        forward-zone:
                                name: "subdomain2.active-directory.com."
                                forward-addr: 10.1.0.30
                                forward-addr: 10.1.0.40
                                forward-addr: 2001:xxxx:xxxx:1::30
                                forward-addr: 2001:xxxx:xxxx:1::40
                                forward-first: yes
                                forward-no-cache: yes
                        

                        After this pfSense can lookup to any AD ✌ record.

                        Latest stable pfSense on 2x XG-7100 and 1x Intel Xeon Server, running mutiWAN, he.net IPv6, pfBlockerNG-devel, HAProxy-devel, Syslog-ng, Zabbix-agent, OpenVPN, IPsec site-to-site, DNS-over-TLS...
                        Unifi AP-AC-LR with EAP RADIUS, US-24

                        1 Reply Last reply Reply Quote 0
                        • dragoangelD
                          dragoangel
                          last edited by dragoangel

                          @free4 but still I can't authorize via FreeRADIUS.

                          1. Plaintext LDAP over 389 is not secure and MUSN'T be used, but atleast it suceffully connect to dc1.subdomain1.active-directory.com. Still strange logs appiers:
                          Mar 29 12:53:29	radiusd	13316	(0) Login incorrect (Failed retrieving values required to evaluate condition): [someuser] (from client pfsense port 0) someuser
                          Mar 29 12:53:29	radiusd	13316	rlm_ldap (ldap): Opening additional connection (1), 1 of 1 pending slots used
                          Mar 29 12:53:29	radiusd	13316	Need 1 more connections to reach min connections (1)
                          Mar 29 12:53:29	radiusd	13316	rlm_ldap (ldap): Deleting connection (0) - Was referred to a different LDAP server
                          Mar 29 12:53:29	radiusd	13316	rlm_ldap (ldap): Opening additional connection (0), 1 of 1 pending slots used
                          

                          Deleting connection (0) - Was referred to a different LDAP server is really strange one.
                          Another case is: filter issues? What is correct filter ro MS AD? I saw many examples but still all diferent. My current config:
                          Filter: (sAMAccountName=%{%{Stripped-User-Name}:-%{User-Name}})
                          Base Filter: (objectClass=*)

                          1. For my configuration LDAPS dosn't works.
                            Root and Intermidiate CA with DC Certs in pfSense Cert Manager. I genereted CSR on DCs and signed them by Intermidiate CA on pfSensne after witch imported them to DCs. Create GPO to put Root CA to Trusted, and Intermidiate CA to Intermidiate CAs store. All DCs trust each-other fine.
                            But in SystemLogs:
                          rlm_ldap (ldap): Bind with CN=some-user,CN=Users,DC=subdomain1,DC=active-directory,DC=com to ldap://dc1.subdomain1.active-directory.com:636 failed: Can't contact LDAP server
                          

                          Where to look why it doesn't work?
                          I already checked:

                          • telnet to dc1.subdomain1.active-directory.com:636 from pfSense works;
                          • dc1.subdomain1.active-directory.com is work with correct SSL certificate. Tested from my PC via LDAP utility.

                          Tried FreeRADIUS LDAP config many combinations:

                          • SSL CA Certificate: none (auto) or choose Root CA or choose Intermidiate CA
                          • SSL Server Certificate: none (auto) or choose DC1 Server CA
                          • Choose Certificate Verification Method: tried all of them.

                          I gived up, and begin use Windows Radius over pfSense FreeRADIUS ☹

                          P.S.
                          @soheil-amiri have same issue in SystemLog: Deleting connection (0) - Was referred to a different LDAP server
                          The only info on Inet about this is https://github.com/FreeRADIUS/freeradius-server/issues/1969
                          But I can't understand how them can be referred to a different LDAP server, and how do I figure out what this server is?

                          Latest stable pfSense on 2x XG-7100 and 1x Intel Xeon Server, running mutiWAN, he.net IPv6, pfBlockerNG-devel, HAProxy-devel, Syslog-ng, Zabbix-agent, OpenVPN, IPsec site-to-site, DNS-over-TLS...
                          Unifi AP-AC-LR with EAP RADIUS, US-24

                          1 Reply Last reply Reply Quote 0
                          • L
                            luisenrique
                            last edited by

                            great explanation.. when i start to setup captive portal/radius i not found any solution like described here... them i configured my enviroment adding a radius server role on domain controller to setup.. and today is working well .. for example making filted setting calback option adding MAC Adress autorize to connect to the user setting on AD..
                            but is good to know maybe in near future i wiil make my setup like described here
                            thanks

                            F 1 Reply Last reply Reply Quote 0
                            • F
                              free4 Rebel Alliance @luisenrique
                              last edited by

                              @luisenrique pfsense support Microsoft AD authentication for captive portal for out of the box, why would you need a radius server?

                              dragoangelD 1 Reply Last reply Reply Quote 1
                              • dragoangelD
                                dragoangel @free4
                                last edited by dragoangel

                                @free4 for my radius needed to authorize of WPA ESK. And pfSense authorization for MS AD is poor on second dc controller. Only one option for second controller create additional "connection". Most people who care about safety have 2 DC in domain, or maybe even more. When freeRadius have load-balacer with failover, except it not working 😆

                                Latest stable pfSense on 2x XG-7100 and 1x Intel Xeon Server, running mutiWAN, he.net IPv6, pfBlockerNG-devel, HAProxy-devel, Syslog-ng, Zabbix-agent, OpenVPN, IPsec site-to-site, DNS-over-TLS...
                                Unifi AP-AC-LR with EAP RADIUS, US-24

                                1 Reply Last reply Reply Quote 0
                                • S
                                  soheil.amiri
                                  last edited by

                                  hi @free4
                                  do you have any idea about this error ?

                                  Login incorrect ( failed retrieving values required to evaluate condition )
                                  

                                  it would so nice to solve this issue.

                                  1 Reply Last reply Reply Quote 1
                                  • J
                                    jt
                                    last edited by jt

                                    EDIT: turns out i missed an important part of the logs - the is actually freeradius thinks my user's password is incorrect ("if (ok && User-Password) -> FALSE"), so the "Auth-Type := LDAP" is actually ignored correctly. but now the question is, what's different in the live setup via CISCO WLC 2504, in comparison to running radtest, which authenticates just fine :/

                                    *has this been resolved?
                                    I put together bits and pieces from various forums, and kinda got this working, but, the only way to get an LDAP user authenticated, is to run
                                    "radtest <user> <pass> 127.0.0.1 1812 <secret>"
                                    which returns Access-Accept

                                    if I try to login to a real WLAN (cisco WLC 2504) hooked up to the same freeradius, the user gets Authenticated, but not Authorized - according to logs
                                    "ERROR: No Auth-Type found: rejecting the user via Post-Auth-Type = Reject
                                    (3) Failed to authenticate the user"

                                    a "Auth-Type := LDAP" is configured in case of successfull authentication, which is correctly respected when testing locally with radtest (see above), however, the live test receives "Access-Rejected" with the error message listed above.*

                                    F 1 Reply Last reply Reply Quote 0
                                    • F
                                      free4 Rebel Alliance @jt
                                      last edited by free4

                                      This post is deleted!
                                      1 Reply Last reply Reply Quote 0
                                      • O
                                        opti2k4
                                        last edited by opti2k4

                                        try this:

                                        vi /usr/local/etc/raddb/sites-enabled/default

                                        add following in authorize {} block, restart freeradius

                                             if (!control:Auth-Type) {
                                                    ldap
                                        
                                                    if (ok && User-Password) {
                                                            update {
                                                            control:Auth-Type := LDAP
                                                            }
                                                    }
                                            }
                                            expiration
                                            logintime
                                        

                                        Auth server under System - User Manager - Authentication servers must use PAP.

                                        EDIT: on every freeradius config change this gets deleted, so you need to copy/paste and restart freeradius server every time :/.

                                        F 1 Reply Last reply Reply Quote 0
                                        • F
                                          free4 Rebel Alliance @opti2k4
                                          last edited by

                                          @opti2k4 please have a look go https://forum.netgate.com/topic/140135/how-connect-freeradius-to-ms-ad/8

                                          O 1 Reply Last reply Reply Quote 0
                                          • O
                                            opti2k4 @free4
                                            last edited by

                                            @free4 that works until you make a change on freeradius that causes service to restart. Then added stuff is gone.

                                            There is also another problem, OTP is useless. I can connect to VPN without using OTP even though user is configured with OTP.

                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post
                                            Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.