Skip to content

Commit

Permalink
is_dn() now also accepts flags and passes it to str2dn()
Browse files Browse the repository at this point in the history
  • Loading branch information
stroeder committed Jul 24, 2016
1 parent e9fca60 commit b7b5999
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Lib/ldap/dn.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
See http://www.python-ldap.org/ for details.
\$Id: dn.py,v 1.15 2016/07/24 15:43:03 stroeder Exp $
\$Id: dn.py,v 1.16 2016/07/24 15:58:26 stroeder Exp $
Compability:
- Tested with Python 2.0+
Expand Down Expand Up @@ -110,14 +110,14 @@ def explode_rdn(rdn,notypes=0,flags=0):
return ['='.join((atype,escape_dn_chars(avalue or ''))) for atype,avalue,dummy in rdn_decomp]


def is_dn(s):
def is_dn(s,flags=0):
"""
Returns True is `s' can be parsed by ldap.dn.str2dn() like as a
distinguished host_name (DN), otherwise False is returned.
"""
try:
str2dn(s)
except Exception, err:
str2dn(s,flags)
except Exception:
return False
else:
return True

0 comments on commit b7b5999

Please sign in to comment.