This Python class represents a single CN as an object derived from the DN class.
class CN(DN):
__cn = ""
def __init__( self, dn ):
items = dn.split( ",", 1 )
if items[0][:2] == "cn":
self.__cn = items[0][3:]
DN.__init__( self, items[1] )
if self.__cn == "" and self.__o == "":
raise ValueError, "CN requires values for both cn and o"
def toString(self):
return "cn="+self.__cn+","+DN.toString(self)
def selftest_passes():
cn1 = CN("cn=c,o=a");
cn2 = CN("cn=d,ou=b,o=a");
return (cn1.toString() == "cn=c,o=a" and
cn2.toString() == "cn=d,ou=b,o=a")
assert( selftest_passes() )
© 2008 Novell, Inc. All Rights Reserved.