openerp-community team mailing list archive
-
openerp-community team
-
Mailing list archive
-
Message #00359
[Merge] lp:~openerp-community/openobject-addons/stefan-therp_lp794450 into lp:openobject-addons
Stefan Rijnhart (Therp) has proposed merging lp:~openerp-community/openobject-addons/stefan-therp_lp794450 into lp:openobject-addons.
Requested reviews:
OpenERP Core Team (openerp)
Related bugs:
Bug #794450 in OpenERP Addons: "[users_ldap] Wishlist: allow anonymous bind"
https://bugs.launchpad.net/openobject-addons/+bug/794450
For more details, see:
https://code.launchpad.net/~openerp-community/openobject-addons/stefan-therp_lp794450/+merge/63831
--
https://code.launchpad.net/~openerp-community/openobject-addons/stefan-therp_lp794450/+merge/63831
Your team OpenERP Community is subscribed to branch lp:~openerp-community/openobject-addons/stefan-therp_lp794450.
=== modified file 'users_ldap/users_ldap.py'
--- users_ldap/users_ldap.py 2011-04-29 11:22:51 +0000
+++ users_ldap/users_ldap.py 2011-06-08 09:43:25 +0000
@@ -37,14 +37,15 @@
ondelete='cascade'),
'ldap_server': fields.char('LDAP Server address', size=64, required=True),
'ldap_server_port': fields.integer('LDAP Server port', required=True),
- 'ldap_binddn': fields.char('LDAP binddn', size=64, required=True),
- 'ldap_password': fields.char('LDAP password', size=64, required=True),
+ 'ldap_binddn': fields.char('LDAP binddn', size=64),
+ 'ldap_password': fields.char('LDAP password', size=64),
'ldap_filter': fields.char('LDAP filter', size=64, required=True),
'ldap_base': fields.char('LDAP base', size=64, required=True),
'user': fields.many2one('res.users', 'Model User',
help="Model used for user creation"),
'create_user': fields.boolean('Create user',
help="Create the user if not in database"),
+ 'anonymous': fields.boolean('Anonymous bind'),
}
_defaults = {
'ldap_server': lambda *a: '127.0.0.1',
@@ -75,14 +76,15 @@
action_obj = pool.get('ir.actions.actions')
cr.execute("""
SELECT id, company, ldap_server, ldap_server_port, ldap_binddn, ldap_password,
- ldap_filter, ldap_base, "user", create_user
+ ldap_filter, ldap_base, "user", create_user, anonymous
FROM res_company_ldap
- WHERE ldap_server != '' and ldap_binddn != '' ORDER BY sequence""")
+ WHERE ldap_server != '' and anonymous = TRUE or ldap_binddn != '' ORDER BY sequence""")
for res_company_ldap in cr.dictfetchall():
logger.debug(res_company_ldap)
try:
l = ldap.open(res_company_ldap['ldap_server'], res_company_ldap['ldap_server_port'])
- if l.simple_bind_s(res_company_ldap['ldap_binddn'], res_company_ldap['ldap_password']):
+ if (res_company_ldap['anonymous'] or
+ l.simple_bind_s(res_company_ldap['ldap_binddn'], res_company_ldap['ldap_password'])):
base = res_company_ldap['ldap_base']
scope = ldap.SCOPE_SUBTREE
filter = filter_format(res_company_ldap['ldap_filter'], (login,))
@@ -150,8 +152,9 @@
for res_company_ldap in user.company_id.ldaps:
try:
l = ldap.open(res_company_ldap.ldap_server, res_company_ldap.ldap_server_port)
- if l.simple_bind_s(res_company_ldap.ldap_binddn,
- res_company_ldap.ldap_password):
+ if (res_company_ldap.anonymous or
+ l.simple_bind_s(res_company_ldap.ldap_binddn,
+ res_company_ldap.ldap_password)):
base = res_company_ldap.ldap_base
scope = ldap.SCOPE_SUBTREE
filter = filter_format(res_company_ldap.ldap_filter, (user.login,))
=== modified file 'users_ldap/users_ldap_view.xml'
--- users_ldap/users_ldap_view.xml 2011-01-14 00:11:01 +0000
+++ users_ldap/users_ldap_view.xml 2011-06-08 09:43:25 +0000
@@ -12,8 +12,16 @@
<form string="LDAP Configuration">
<field name="ldap_server"/>
<field name="ldap_server_port"/>
- <field name="ldap_binddn"/>
- <field name="ldap_password"/>
+ <field name="ldap_binddn" attrs="{
+ 'required': [('anonymous', '!=', True)],
+ 'readonly': [('anonymous', '=', True)],
+ }"/>
+ <field name="ldap_password" attrs="{
+ 'required': [('anonymous', '!=', True)],
+ 'readonly': [('anonymous', '=', True)],
+ }"/>
+ <field name="anonymous"/>
+ <newline/>
<field name="ldap_base"/>
<field name="ldap_filter"/>
<field name="create_user"/>
Follow ups