django-auth-ldap验证失败(django-auth-ldap failed authentication)
我正在尝试在我的项目中使用Django-Auth-Ldap (Django 1.6,Python 2.7),但它无法正常工作。
我的活动目录shema是:
我已经通过安装ldap-utils包测试了cmd行上的连接
sudo apt-get install ldap-utils ldapsearch -H ldap://domain.com -D "ou=Resources,ou=Company, dc=domain,dc=com" -U "user_name" -w "user_password" -v -d 1
连接测试工作正常。
我使用下面的代码来测试shell中的python-ldap连接:
import ldap con = ldap.initialize('ldap://domain.com') con.simple_bind_s('User_mail', 'User_password') results = con.search_s('ou=Users,ou=Resources,ou=Company,dc=domain,dc=com', ldap.SCOPE_SUBTREE, "(cn=User_name)")
python-ldap连接正常。
- 我的问题是如何从我的django登录界面验证AD用户?
settings.py:
import ldap from django_auth_ldap.config import LDAPSearch # The URL of the LDAP server. AUTH_LDAP_SERVER_URI = "ldap://domain.com" AUTH_LDAP_BIND_DN = "cn='User_name',ou=Resources,ou=Company,dc=domain,dc=com" AUTH_LDAP_BIND_PASSWORD = "User_password" AUTH_LDAP_USER_SEARCH = LDAPSearch("ou=Users,ou=Resources,ou=Company,dc=domain,dc=com",ldap.SCOPE_SUBTREE, "(cn=%(user)s)") AUTH_LDAP_GLOBAL_OPTIONS = { ldap.OPT_REFERRALS : False } AUTHENTICATION_BACKENDS = ( 'django_auth_ldap.backend.LDAPBackend', 'django.contrib.auth.backends.ModelBackend', )
views.py:
from django_auth_ldap.backend import LDAPBackend auth = LDAPBackend() user = auth.authenticate(username="User_name", password="User_password")
在文件django-ldap-debug.log中我有这个错误:
Caught LDAPError while authenticating User_name: INVALID_CREDENTIALS({'info': '80090308: LdapErr: DSID-0C0903A9, comment: AcceptSecurityContext error, data 52e, v1db1', 'desc': 'Invalid credentials'},)
I'm trying to use Django-Auth-Ldap in my project (Django 1.6, Python 2.7) but it is not working.
My active Directory shema is:
I've tested the connection on the cmd line by installing the ldap-utils package
sudo apt-get install ldap-utils ldapsearch -H ldap://domain.com -D "ou=Resources,ou=Company, dc=domain,dc=com" -U "user_name" -w "user_password" -v -d 1
The connection test works fine.
I am using below code to test python-ldap connection from the shell:
import ldap con = ldap.initialize('ldap://domain.com') con.simple_bind_s('User_mail', 'User_password') results = con.search_s('ou=Users,ou=Resources,ou=Company,dc=domain,dc=com', ldap.SCOPE_SUBTREE, "(cn=User_name)")
python-ldap connection works fine.
- My problem is how to authenticate AD users from my django login interface?
settings.py:
import ldap from django_auth_ldap.config import LDAPSearch # The URL of the LDAP server. AUTH_LDAP_SERVER_URI = "ldap://domain.com" AUTH_LDAP_BIND_DN = "cn='User_name',ou=Resources,ou=Company,dc=domain,dc=com" AUTH_LDAP_BIND_PASSWORD = "User_password" AUTH_LDAP_USER_SEARCH = LDAPSearch("ou=Users,ou=Resources,ou=Company,dc=domain,dc=com",ldap.SCOPE_SUBTREE, "(cn=%(user)s)") AUTH_LDAP_GLOBAL_OPTIONS = { ldap.OPT_REFERRALS : False } AUTHENTICATION_BACKENDS = ( 'django_auth_ldap.backend.LDAPBackend', 'django.contrib.auth.backends.ModelBackend', )
views.py:
from django_auth_ldap.backend import LDAPBackend auth = LDAPBackend() user = auth.authenticate(username="User_name", password="User_password")
In the file django-ldap-debug.log I have this error:
Caught LDAPError while authenticating User_name: INVALID_CREDENTIALS({'info': '80090308: LdapErr: DSID-0C0903A9, comment: AcceptSecurityContext error, data 52e, v1db1', 'desc': 'Invalid credentials'},)
原文:https://stackoverflow.com/questions/40048962
最满意答案
您应该创建一个HTML字符串,并在循环后立即附加所有内容。 还使用一个公共类,所以你只需要一个处理程序!
var buttonList = ""; for(i=1;i<=10;i++){ buttonList += '<input type="button" id="btn_id'+i+'" class="button-list" value="button#'+i+'">'; } $('.btn_tableform').append(buttonList); $(".button-list").click(function() { alert(this.value); });
You should create an HTML string and append that all at once after the loop. Also use a common class so you only need 1 handler!
var buttonList = ""; for(i=1;i<=10;i++){ buttonList += '<input type="button" id="btn_id'+i+'" class="button-list" value="button#'+i+'">'; } $('.btn_tableform').append(buttonList); $(".button-list").click(function() { alert(this.value); });
相关问答
更多-
jquery:设置添加的输入的值,一次追加一个(jquery: set the value of the added input with the append one at a time)[2022-10-15]
你的问题不在jquery或jscript执行的附加函数上。 那些追加id不存在.click因为它们不在dom上所以你应该使用jquery .live | .on jquery动作而不是.on juqery.on Your problem it's not on the append function it's on the jquery or jscript execution. Those append id's don't exists for .click because they are not o ... -
如果提交的字段为空,则禁止添加/附加输入类型=“按钮”(Prevent from adding/append input type=“button” if submitted field is empty)[2022-04-21]
警报后返回false。 $('#add').click(function(){ var newToList = $('#list-input').val(); if(newToList == ""){ alert("Please input some list to do"); return false; } $('#mylist').append('- ' + newToList + '
你可以这样做: $(document).ready(function(){ $(document).on('click', ".btn2", function () { var buttonContent = $(this).html(); $("ol").append("- " + buttonContent + "
"); }); }); You can do it like this: $(document).ready(function(){ $(docum ...jQuery - 追加ajax结果(jQuery - append ajax result)[2023-10-13]
在ajax部分 var result=""; $.ajax({ type: 'GET', url: 'ajax.php', data: { word: word }, dataType: 'json', success: function (data) { if (data.length > 0) { $.each(data, function(i, item) { res ...jQuery:为什么有人想要附加到一个封闭的列表元素?(jQuery: why would someone want to append to a closed list element?)[2022-08-02]
这是直接的DOM操作,并且在浏览器中“查看源”时不会显示 是。 不要使用“查看源代码”,请在浏览器的开发人员工具(F12)中查看DOM。 我误读了这是元素之后的追加吗? 是。 http://api.jquery.com/append/ 话虽这么说,不要通过连接字符串来构建HTML。 一旦您使用的字符串包含在HTML中具有含义的字符(如< , >或& ,这将会中断。 这至少可以在answer.option发生。 jQuery允许将元素属性作为带有键和值的对象传递,这样可以安全使用,并且更少涉及' + '输入。 ...这是一个基本的html引用问题,如果在里面你将以这种方式使用html 那么代码将运行时没有任何javaScript错误。 使用此修订代码,希望这一个适合您JQuery追加和绑定(JQuery append and bind)[2023-11-21]
我认为你所追求的是新的jQuery 1.3特性之一 - 现场活动。 请参阅http://docs.jquery.com/Events/live 。 这适用于我: $(".remove").live("click", function() { $(this).parent().remove(); }); 奖金: 我也使用FF 3.0.5,并且在两个文本框之间有相同的空间量。 如果你的意思是在第二个文本框和按钮之间,那么我必须同意eimaj并且说空白是原因。 I think what you're aft ...jQuery按钮追加空间问题(jQuery button append space issue)[2021-10-21]
修改这个HTMLjQuery追加按钮后添加(jQuery append after the button)[2022-09-19]
问题: 问题出现在以下声明中 $this.find('.cover-attachment').append_html 这将返回undefined因为jQuery上没有方法/属性名称append_html 。 解: Jquery在按钮后追加 要附加HTML,您可以使用append() 。 $this.find('.cover-attachment').append(append_html); 要完全替换/覆盖元素的HTML,请使用html() 。 $this.find('.cover-attachment ...相关文章
更多- Failed to read auto-increment value from storage engine错误的解决方法
- Nutch Job failed异常
- Hadoop “Failed to set setXIncludeAware(true) for parser” 错误
- 解决Eclipse无法打开“Failed to load the JNI shared library”
- 移动MM failed to find resource file{mmiap.xml}
- vicalloy的我与django
- Hive 终端产生的问题 (Failed to start database 'metastore_db', see the next exception for details.)
- solr bin/snapinstaller 报 failed to connect to Solr server
- 新浪微博failed to receive access token
- Hadoop中 "Exceeded MAX_FAILED_UNIQUE_FETCHES”的错误
最新问答
更多- 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
- 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
- OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
- 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
- codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
- 在计算机拍照在哪里进入
- 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
- No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
- 单页应用程序:页面重新加载(Single Page Application: page reload)
- 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
- System.StackOverflow错误(System.StackOverflow error)
- KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
- 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
- android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
- TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
- 企业安全培训的各项内容
- 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
- C#类名中允许哪些字符?(What characters are allowed in C# class name?)
- NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
- 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
- 将多个行和可变行移动到列(moving multiple and variable rows to columns)
- 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
- 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
- Angular $资源不会改变方法(Angular $resource doesn't change method)
- 在Angular 5中不是一个函数(is not a function in Angular 5)
- 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
- 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
- 常见的python rpc和cli接口(Common python rpc and cli interface)
- Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
- 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)