Comments (3)
Thank you very much @kirik . We were facing the exact same issue.
And we replaced as well the module by a bash script.
Here is our version of the script that perform the check against 2 different DN (we have real user and service account)
#!/bin/bash
ourname=ldap_auth.sh
facility=auth
output=$(mktemp)
error=$(mktemp)
log_this () {
echo "$1"
}
log_this "Connection from username: $username at $(date)"
exit_if_ok() {
if [ $status -eq 0 ]; then
numentries=$(awk '/numEntries:/{ne = $3} END{print ne + 0}' "$output")
if [ $numentries -eq 1 ]; then
log_this "User ${username} authenticated successfully"
echo "1" > "${auth_control_file}"
exit 0
fi
fi
}
# child process - try simple shell backgrounding
(
# check email
ldapsearch -x -H ldaps://ldap.domain:636 \
-D "uid=${username},ou=People,o=domain.com" \
-w "${password}" \
-b "ou=People,o=domain.com" \
"uid=${username}" 1>"${output}" 2>"${error}"
status=$?
exit_if_ok
# # check service account
ldapsearch -x -H ldaps://ldap.domaint:636 \
-D "cn=${username},ou=Applications,o=domain.com" \
-w "${password}" \
-b "ou=Applications,o=domain.com" \
"cn=${username}" 1>"${output}" 2>"${error}"
status=$?
exit_if_ok
log_this "User ${username} NOT authenticated"
echo "0" > "${auth_control_file}"
exit 1
) &
# tell openvpn that auth will be deferred
exit 2
from openvpn-auth-ldap.
Had this weird packet losses. I found a workaround (actually solution) using auth-user-pass-verify script which support deferred auth since OpenVPN 2.5+.
Some source links:
https://community.openvpn.net/openvpn/ticket/222
https://github.com/waldner/openvpn-ldap
OpenVPN server config file:
...
script-security 3
auth-user-pass-verify /etc/openvpn/ldap_auth.sh via-env
...
Example of ldap_auth.sh script (use your <BINDDN>
and <BASEDN>
). ldapsearch should be installed where script will run.
#!/bin/bash
ourname=ldap_auth.sh
facility=auth
output=$(mktemp)
error=$(mktemp)
# child process - try simple shell backgrounding
(
ldapsearch -h auth.local -D "cn=${username},<BASEDN>" -b "<BINDDN>" -s base "objectClass=*" 1.1 -w "${password}" 1>"${output}" 2>"${error}"
# save exist status here, otherwise the following assignment resets $?
status=$?
if [ $status -ne 0 ]; then
logger -p "${facility}.err" -t "${ourname}" "There was an error authenticating user ${username} against AD."
logger -p "${facility}.err" -t "${ourname}" "The error was: $(tr '\n' ' ' < "${error}" )" # turn multiline into single line
echo "0" > "${auth_control_file}"
exit 1
fi
# look for the "numEntries" line in the output of ldapsearch
numentries=$(awk '/numEntries:/{ne = $3} END{print ne + 0}' "$output")
if [ $numentries -eq 1 ]; then
logger -p "${facility}.info" -t "{$ourname}" "User ${username} authenticated successfully"
echo "1" > "${auth_control_file}"
exit 0
else
logger -p "${facility}.err" -t "${ourname}" "User ${username} NOT authenticated (user not in group?)"
echo "0" > "${auth_control_file}"
exit 1
fi
) &
# tell openvpn that auth will be deferred
exit 2
After using this you should see deferred auth messages in OpenVPN server log: Username/Password authentication deferred for username 'username'
Hope this will help
from openvpn-auth-ldap.
I opened a PR for this issue #67 which I'm hoping helps solve this issue.
from openvpn-auth-ldap.
Related Issues (20)
- Support OpenVPN Challenge/Response protocol
- Building on recent compilers
- ldaps (TLS) with self signed certificate HOT 6
- LDAP bind failed immediately: Can't contact LDAP server HOT 6
- openldap password expiration still can login
- Authenticate non local users to OpenVPN with openvpn and openvpn-auth-ldap. HOT 5
- Tips to compile plugin on CentOS 7.6
- Plugin and OpenVPN Crashes with error after successful LDAP(ActiveDirectory) Query
- option to build statically
- Configure test fails to add -std=gnu99 on Fedora Rawhide HOT 1
- Compiling on Rhel8 - no Objective-C Compiler support ? HOT 3
- Customized search filters!! HOT 1
- OpenVPN can't get the userworkstations attribute
- Cannot LDAP with win 2016 but LDAP normal with win2012 (active directory)
- Cannot use a Bind Password containing double quotes HOT 1
- plugin does not work if OpenVPN daemon runs as nobody/nogoup and SSL enabled HOT 1
- cannot make it working with google workspace HOT 7
- is it possible to specify VPN client configurations via LDAP return parameters
- Help! configuring "openvpn-auth-ldap"
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from openvpn-auth-ldap.