django python3 ldap_Django使用ldap认证登录

news/2024/7/6 1:56:08 标签: django python3 ldap

一、安装依赖包

yum install gcc libffi-devel python-devel openssl-devel openldap-devel -y

二、安装Python库

pip install python_ldap

pip install django-auth-ldap

三、修改django项目中的setting配置文件

AUTHENTICATION_BACKENDS = (

'django_auth_ldap.backend.LDAPBackend', ##优先使用ldap登录

'django.contrib.auth.backends.ModelBackend', ##ldap登录失败后使用默认登录方式认证

)

AUTH_LDAP_SERVER_URI = "ldap://10.10.xx.xx:389" # ldap服务器地址

AUTH_LDAP_BIND_DN = 'cn=gitlxxxx,ou=Special,dc=xiaoniu,dc=com' # 可为空,也可以填写一个真实的ldap用户

AUTH_LDAP_BIND_PASSWORD = 'git-xxxx'

AUTH_LDAP_USER_SEARCH = LDAPSearch("ou=xxxxxxxxx,dc=xxxxxx,dc=com", ldap.SCOPE_SUBTREE, '(SAMAccountName=%(user)s)') # 第一个参数是搜索的范围

AUTH_LDAP_USER_ATTR_MAP = {"first_name": "givenName", "last_name": "sn", "email": "mail"}

AUTH_LDAP_ALWAYS_UPDATE_USER = True


http://www.niftyadmin.cn/n/1172242.html

相关文章

[PyQt5]基本控件21 - 滚动条QScrollBar

文章目录PyQt5系列文章效果图完整代码PyQt5系列文章 基本控件---1.按钮QPushButton2.标签QLabel3.可编辑框QTextEdit4.文本提示QToolTip5.单行输入框QLineEdit6.消息框QMessageBox7.单选按钮QRadioButton8.下拉列表QComboBox9.图片显示QPixmap10.分组框QGroupBox11.进度条QPro…

CNCF权威调研揭示K8s用户所面临的最大挑战

人们在使用及部署Kubernetes时会遇到各种各样的问题。一些挑战是使用Kubernetes时独有的,其他一些挑战则是伴随着一些技术的使用出现的典型问题。The New Stack发布的《Kubernetes的生态系统状况》报告总结了用户在挑选容器编排解决方案时的不同标准,以及…

Storm--命令行解析

strom的命令行解析 Commands:activateclasspathdeactivatedev-zookeeperdrpchelpjarkilllistlocalconfvaluelogviewermonitornimbusrebalanceremoteconfvaluereplshellsupervisoruiupload-credentialsversionHelp: help help <command> 1.详细解析-常用 1.jar 提交topol…

Python——re模块

re模块 1. 匹配常用方法 (1) findall 返回值&#xff1a;列表&#xff1a;列表中是所有匹配到的项 import re ret re.findall(a,eva egon yuan) #[a, a] print(ret) ret re.findall([a-z],eva egon yuan) #[eva, egon, yuan] print(ret) View Code(2) search ret …

[PyQt5]基本控件22 - 时间编辑框QTimeEdit

文章目录PyQt5系列文章效果图完整代码PyQt5系列文章 基本控件---1.按钮QPushButton2.标签QLabel3.可编辑框QTextEdit4.文本提示QToolTip5.单行输入框QLineEdit6.消息框QMessageBox7.单选按钮QRadioButton8.下拉列表QComboBox9.图片显示QPixmap10.分组框QGroupBox11.进度条QPro…

装ubuntu_10个有趣但毫无用处的ubuntu,Linux命令,装专用

一、cmatrix你应该看过好莱坞大片《骇客帝国》&#xff0c;相信你会对电影中那些神奇的场景着迷。在Neo的眼里任何东西都能以计算机字节流的形式展现&#xff0c;你是否也想做一个很有黑客范儿的数据流的桌面呢&#xff1f;安装cmatrix~#sudo apt-get install cmatrix执行效果~…

Pipeline build step with parameters

build step https://jenkins.io/doc/pipeline/steps/pipeline-build-step/#build-build-a-job 一个任务的执行触发&#xff0c;另外一个任务的执行&#xff0c;以代码的形式。 build: Build a job Triggers a new build for a given job.job Name of a downstream job to build…

[PyQt5]基本控件23 - 日期编辑框QDateEdit

文章目录PyQt5系列文章效果图完整代码PyQt5系列文章 基本控件---1.按钮QPushButton2.标签QLabel3.可编辑框QTextEdit4.文本提示QToolTip5.单行输入框QLineEdit6.消息框QMessageBox7.单选按钮QRadioButton8.下拉列表QComboBox9.图片显示QPixmap10.分组框QGroupBox11.进度条QPro…