def is_dn_equal(dn1, dn2):
 if (not isinstance(dn1, list)):
  dn1 = ldap.dn.str2dn(utf8_encode(dn1))
 if (not isinstance(dn2, list)):
  dn2 = ldap.dn.str2dn(utf8_encode(dn2))
 if (len(dn1) != len(dn2)):
  return False
 for (rdn1, rdn2) in zip(dn1, dn2):
  if (not is_rdn_equal(rdn1, rdn2)):
   return False
 return True

def is_dn_equal ( dn1 , dn2 ) : if ( not isinstance ( dn1 , list ) ) : dn1 = ldap . dn . str2dn ( utf8_encode ( dn1 ) ) if ( not isinstance ( dn2 , list ) ) : dn2 = ldap . dn . str2dn ( utf8_encode ( dn2 ) ) if ( len ( dn1 ) != len ( dn2 ) ) : return False for ( rdn1 , rdn2 ) in zip ( dn1 , dn2 ) : if ( not is_rdn_equal ( rdn1 , rdn2 ) ) : return False return True
return true if and only if the dns are equal .