来源:https://gitee.com/attacker/ldap-password
注:官方原版镜像存在问题,需要修改使用
docker run --name ldap-password -d -p8000:8000 -e LDAP_HOST='ldap://192.168.0.199:389' -e LDAP_ADMIN_USER='cn=admin,dc=hpc,dc=example,dc=com,dc=cn' -e LDAP_ADMIN_PASSWORD=xxxxxxxxxx -e LDAP_BASE_DN='dc=hpc,dc=example,dc=com,dc=cn' docker.example.com/example/ldap-password:20230524
/home # vi /home/ldapmgt/LDAPTool.py
》》
hostargs = os.environ.get("LDAP_HOST")
userargs = os.environ.get("LDAP_ADMIN_USER")
passwdargs = os.environ.get("LDAP_ADMIN_PASSWORD")
baseargs = os.environ.get("LDAP_BASE_DN")
LDAP_HOST = hostargs # LDAP_HOST = 'ldap://172.16.140.118:389'
USER = userargs
PASSWORD = passwdargs
BASE_DN = baseargs
《《
替换如下内容
hostargs = os.environ.get("LDAP_HOST")
if hostargs is None:
hostargs = config['ldap']['LDAP_HOST']
userargs = config['ldap']['LDAP_ADMIN_USER']
passwdargs = config['ldap']['LDAP_PASSWORD']
else:
userargs = os.environ.get("LDAP_ADMIN_USER")
passwdargs = os.environ.get("LDAP_PASSWORD")
userlist = userargs.split(".")
LDAP_HOST = 'ldap://%s' % hostargs # LDAP_HOST = 'ldap://172.16.140.118'
USER = 'cn=%s,dc=%s,dc=%s' % (userlist[0], userlist[1], userlist[2])
PASSWORD = passwdargs
BASE_DN = "dc=%s,dc=%s" % (userlist[1], userlist[2])
docker commit ldap-password docker.example.com/example/ldap-password:20230524
docker restart ldap-password