diff --git a/base/univention-python/modules/uldap.py b/base/univention-python/modules/uldap.py index 7c1b466..2bfb9e5 100644 --- a/base/univention-python/modules/uldap.py +++ b/base/univention-python/modules/uldap.py @@ -569,8 +569,14 @@ def compare_dn(cls, a, b): True >>> compare_dn(r'foo=\31', r'foo=1') True + >>> compare_dn(r'Uid=Foo', r'uid=foo') + True """ - return [sorted((x.lower(), y, z) for x, y, z in rdn) for rdn in ldap.dn.str2dn(a)] == [sorted((x.lower(), y, z) for x, y, z in rdn) for rdn in ldap.dn.str2dn(b)] + def normalize(attr, value): + if attr.lower() in _IGNORE_CASE_ATTRIBUTES: + value = value.lower() + return value + return [sorted((x.lower(), normalize(x, y), z) for x, y, z in rdn) for rdn in ldap.dn.str2dn(a)] == [sorted((x.lower(), normalize(x, y), z) for x, y, z in rdn) for rdn in ldap.dn.str2dn(b)] def __getstate__(self): _d = univention.debug.function('uldap.__getstate__') @@ -611,6 +617,8 @@ def _handle_referral(self, exception): raise ldap.CONNECT_ERROR('Bad referral "%s"' % (exc,)) +_IGNORE_CASE_ATTRIBUTES = set(['keyrecord', 'locrecord', 'sigrecord', 'a6record', 'aaaarecord', 'arecord', 'acl', 'associateddomain', 'automountinformation', 'buildingname', 'businesscategory', 'cnamerecord', 'carlicense', 'certrecord', 'co', 'dnsclass', 'dnamerecord', 'dc', 'departmentnumber', 'description', 'destinationindicator', 'dhcpaddressstate', 'dhcpassignedhostname', 'dhcpclassdata', 'dhcpclientid', 'dhcpcomments', 'dhcpdnszoneserver', 'dhcpdomainname', 'dhcperrorlog', 'dhcpfailoverendpointstate', 'dhcpfailoverprimaryserver', 'dhcpfailoversecondaryserver', 'dhcphwaddress', 'dhcpimplementation', 'dhcpkeyalgorithm', 'dhcpoption', 'dhcppermitlist', 'dhcprange', 'dhcprange6', 'dhcprequestedhostname', 'dhcpstatements', 'dhcpversion', 'displayname', 'dnqualifier', 'documentidentifier', 'documentlocation', 'documentpublisher', 'documenttitle', 'documentversion', 'domaincomponent', 'drink', 'email', 'emailaddress', 'employeenumber', 'employeetype', 'emptyattributes', 'envelopeheader', 'facsimiletelephonenumber', 'favouritedrink', 'fax', 'fixedattributes', 'friendlycountryname', 'gecos', 'hinforecord', 'homepostaladdress', 'host', 'houseidentifier', 'info', 'iphostnumber', 'ipnetmasknumber', 'ipnetworknumber', 'isoxgroup', 'isoxuser', 'janetmailbox', 'kxrecord', 'knowledgeinformation', 'leavemessagesonserver', 'localdomainname', 'localrecipient', 'mdrecord', 'minforecord', 'mxrecord', 'macaddress', 'mail', 'mailalternativeaddress', 'mailforwardaddress', 'mailglobalspamfolder', 'mailprimaryaddress', 'mailrelay', 'maildisclaimertemplate', 'maildrop', 'mailsource', 'mgrprfc822mailmember', 'naptrrecord', 'nsrecord', 'nxtrecord', 'name', 'nispublickey', 'nissecretkey', 'olcaccess', 'olcallows', 'olcargsfile', 'olcattributeoptions', 'olcattributetypes', 'olcauthidrewrite', 'olcauthzpolicy', 'olcauthzregexp', 'olcbackend', 'olcconfigdir', 'olcconfigfile', 'olcconstraintattribute', 'olcdbdirectory', 'olcdbenvflags', 'olcdbindex', 'olcdisallows', 'olcditcontentrules', 'olcextraattrs', 'olcldapsyntaxes', 'olclimits', 'olcloglevel', 'olcmoduleload', 'olcobjectclasses', 'olcobjectidentifier', 'olcpasswordhash', 'olcplugin', 'olcreplica', 'olcrequires', 'olcrestrict', 'olcrootdse', 'olcsecurity', 'olcserverid', 'olcsortvals', 'olcsyncrepl', 'olcupdateref', 'organizationalstatus', 'oxaccess', 'oxaccessforum', 'oxaccesspinboardwrite', 'oxaccessprojects', 'oxaccessresources', 'oxaccessrssbookmarks', 'oxaccesssyncml', 'oxaccessusm', 'oxadmindaemonversion', 'oxanniversary', 'oxbirthday', 'oxbranches', 'oxcityhome', 'oxcityother', 'oxcommercialregister', 'oxcontextidnum', 'oxcontextname', 'oxcountrybusiness', 'oxcountryhome', 'oxcountryother', 'oxdbserver', 'oxdepartment', 'oxdisplayname', 'oxdomainname', 'oxemail2', 'oxemail3', 'oxenableresource', 'oxfaxbusiness', 'oxfaxhome', 'oxfaxother', 'oxgroupwareversion', 'oxguiversion', 'oxhomemta', 'oxhomeserver', 'oximapserver', 'oxinstantmessenger1', 'oxinstantmessenger2', 'oxintegrationversion', 'oxlanguage', 'oxmanagername', 'oxmarialstatus', 'oxmiddlename', 'oxmobilebusiness', 'oxmobilehome', 'oxnickname', 'oxnote', 'oxnumofchildren', 'oxposition', 'oxpostalcodehome', 'oxpostalcodeother', 'oxprofession', 'oxquota', 'oxresourceadmin', 'oxresourcemailaddress', 'oxresourceobject', 'oxsalesvolume', 'oxspousename', 'oxstatebusiness', 'oxstatehome', 'oxstateother', 'oxstreethome', 'oxstreetother', 'oxsuffix', 'oxtaxid', 'oxtelephoneassistant', 'oxtelephonebusiness1', 'oxtelephonebusiness2', 'oxtelephonecar', 'oxtelephonecompany', 'oxtelephonehome1', 'oxtelephonehome2', 'oxtelephoneip', 'oxtelephoneother', 'oxtelephonepager', 'oxtelephonetelex', 'oxtelephonettydd', 'oxtimezone', 'oxurl', 'oxuserfield01', 'oxuserfield02', 'oxuserfield03', 'oxuserfield04', 'oxuserfield05', 'oxuserfield06', 'oxuserfield07', 'oxuserfield08', 'oxuserfield09', 'oxuserfield10', 'oxuserfield11', 'oxuserfield12', 'oxuserfield13', 'oxuserfield14', 'oxuserfield15', 'oxuserfield16', 'oxuserfield17', 'oxuserfield18', 'oxuserfield19', 'oxuserfield20', 'oxvacation', 'oxvacationdays', 'oxvacationsubject', 'oxvacationtext', 'ptrrecord', 'personaltitle', 'physicaldeliveryofficename', 'pkcs9email', 'postofficebox', 'postaladdress', 'postalcode', 'preferredlanguage', 'printermodel', 'printeruri', 'prohibitedobjectclasses', 'prohibitedusername', 'protocol', 'pwhistory', 'qmailprefix', 'relativedomainname', 'remotepassword', 'remoteserver', 'remoteuser', 'requiredobjectclasses', 'rfc822mailbox', 'roomnumber', 'soarecord', 'srvrecord', 'sambaacctflags', 'sambadomainname', 'sambahomedrive', 'sambahomepath', 'sambalmpassword', 'sambalogonhours', 'sambalogonscript', 'sambantpassword', 'sambaoptionname', 'sambapasswordhistory', 'sambaprimarygroupsid', 'sambaprofilepath', 'sambasid', 'sambasidlist', 'sambasharename', 'sambastringlistoption', 'sambatrustflags', 'sambauserworkstations', 'serialnumber', 'street', 'streetaddress', 'txtrecord', 'templatehtml', 'templatetext', 'textencodedoraddress', 'ucsschoolhomesharefileserver', 'ucsschoolrecorduid', 'ucsschoolrole', 'ucsschoolschool', 'ucsschoolsourceuid', 'uid', 'uniqueidentifier', 'univentionadminpropertydefault', 'univentionadminpropertydeleteobjectclass', 'univentionadminpropertydeletevalues', 'univentionadminpropertylayoutposition', 'univentionadminpropertylayouttabname', 'univentionadminpropertylongdescription', 'univentionadminpropertymultivalue', 'univentionadminpropertyshortdescription', 'univentionappcategory', 'univentionappcontact', 'univentionappdescription', 'univentionappinstalledonserver', 'univentionapplongdescription', 'univentionappmaintainer', 'univentionappname', 'univentionappscreenshot', 'univentionappvendor', 'univentionappwebsite', 'univentionappwebsitemaintainer', 'univentionappwebsitevendor', 'univentionassignedprinter', 'univentionbirthday', 'univentioncanonicalrecipientrewriteenabled', 'univentioncanonicalsenderrewriteenabled', 'univentioncomputerportal', 'univentioncomputersobject', 'univentiondefaultkdeprofiles', 'univentiondefaultkolabhomeserver', 'univentiondefaultoxhomeserver', 'univentiondefaultscalixmailnode', 'univentiondhcpbroadcastaddress', 'univentiondhcpentry', 'univentiondhcpfailoverpeer', 'univentiondhcpfixedaddress', 'univentiondhcpobject', 'univentiondnsforwardzone', 'univentiondnsobject', 'univentiondnsreversezone', 'univentionfetchmailaddress', 'univentionfetchmailkeepmailonserver', 'univentionfetchmailprotocol', 'univentionfetchmailprotocoltype', 'univentionfetchmailserver', 'univentionfetchmailusessl', 'univentiongroupsobject', 'univentioninternalalternativemailaddress', 'univentioninternalprimarymailaddress', 'univentioninventorynumber', 'univentioniprange', 'univentionlicenseaccounts', 'univentionlicensebasedn', 'univentionlicenseclients', 'univentionlicensecorporateclients', 'univentionlicenseenddate', 'univentionlicensegroupwareaccounts', 'univentionlicensekeyid', 'univentionlicensemanagedclients', 'univentionlicensemodule', 'univentionlicenseoemproduct', 'univentionlicenseobject', 'univentionlicensephysicalservers', 'univentionlicensepremiumsupport', 'univentionlicenseproduct', 'univentionlicenseserverinstances', 'univentionlicenseservers', 'univentionlicensesignature', 'univentionlicensesupport', 'univentionlicensethinclients', 'univentionlicensetype', 'univentionlicenseusers', 'univentionlicenseversion', 'univentionlicensevirtualdesktopclients', 'univentionlicensevirtualdesktopusers', 'univentionlicensevirtualdesktops', 'univentionlicenseuniventiondesktops', 'univentionmailacl', 'univentionmailhomeserver', 'univentionmailmember', 'univentionmailobject', 'univentionmailsharedfolderdeliveryaddress', 'univentionmailuserquota', 'univentionmailserverfqdn', 'univentionmetadirectorynames', 'univentionmetadirectorypreviousdirectory', 'univentionnagiosactivechecksenabled', 'univentionnagioscheckargs', 'univentionnagioscheckcommand', 'univentionnagioscheckperiod', 'univentionnagiosemail', 'univentionnagiosenabled', 'univentionnagioseventhandlerenabled', 'univentionnagioshostname', 'univentionnagiosmaxcheckattempts', 'univentionnagiosnormalcheckinterval', 'univentionnagiosnotificationinterval', 'univentionnagiosnotificationoptions', 'univentionnagiosnotificationperiod', 'univentionnagiosparent', 'univentionnagiospassivechecksenabled', 'univentionnagiosretrycheckinterval', 'univentionnagiostimeperiod', 'univentionnagiosusenrpe', 'univentionnetmask', 'univentionnetwork', 'univentionnetworksobject', 'univentionnextip', 'univentionoperatingsystem', 'univentionoperatingsystemversion', 'univentionoxmember', 'univentionoxsharedfolderdeliveryaddress', 'univentionpasswordselfserviceemail', 'univentionpolicyobject', 'univentionpolicyreference', 'univentionportalcssbackground', 'univentionportaldisplayname', 'univentionportalentryauthrestriction', 'univentionportalentrycategory', 'univentionportalentrydescription', 'univentionportalentrydisplayname', 'univentionportalentrylink', 'univentionportalentryportal', 'univentionportalfontcolor', 'univentionprinteracltype', 'univentionprintergroupmember', 'univentionprinterlocation', 'univentionprintermodel', 'univentionprinterpriceperjob', 'univentionprinterpriceperpage', 'univentionprinterquotasupport', 'univentionprintersambaname', 'univentionprinterspoolhost', 'univentionprinteruri', 'univentionprinteruseclientdriver', 'univentionprintersobject', 'univentionpublicalternativemailaddress', 'univentionpublicprimarymailaddress', 'univentionregistry', 'univentionsamba4sid', 'univentionsambaprivilegelist', 'univentionscalixmailnodehost', 'univentionsharedirectorymode', 'univentionsharegid', 'univentionsharehost', 'univentionsharenfsallowed', 'univentionsharenfscustomsetting', 'univentionsharenfsrootsquash', 'univentionsharenfssubtree', 'univentionsharenfssync', 'univentionsharepath', 'univentionsharesambablocksize', 'univentionsharesambablockinglocks', 'univentionsharesambabrowseable', 'univentionsharesambacreatemode', 'univentionsharesambacscpolicy', 'univentionsharesambacustomsetting', 'univentionsharesambadirectorymode', 'univentionsharesambadirectorysecuritymode', 'univentionsharesambadosfilemode', 'univentionsharesambafakeoplocks', 'univentionsharesambaforcecreatemode', 'univentionsharesambaforcedirectorymode', 'univentionsharesambaforcedirectorysecuritymode', 'univentionsharesambaforcegroup', 'univentionsharesambaforcesecuritymode', 'univentionsharesambaforceuser', 'univentionsharesambahidefiles', 'univentionsharesambahideunreadable', 'univentionsharesambahostsallow', 'univentionsharesambahostsdeny', 'univentionsharesambainheritacls', 'univentionsharesambainheritowner', 'univentionsharesambainheritpermissions', 'univentionsharesambainvalidusers', 'univentionsharesambalevel2oplocks', 'univentionsharesambalocking', 'univentionsharesambamsdfs', 'univentionsharesambaname', 'univentionsharesambantaclsupport', 'univentionsharesambaoplocks', 'univentionsharesambapostexec', 'univentionsharesambapreexec', 'univentionsharesambapublic', 'univentionsharesambasecuritymode', 'univentionsharesambastrictlocking', 'univentionsharesambavfsobjects', 'univentionsharesambavalidusers', 'univentionsharesambawritelist', 'univentionsharesambawriteable', 'univentionshareuid', 'univentionsharewebaccesshordeauth', 'univentionsharewebaccessipaddress', 'univentionsharewebaccessname', 'univentionsharewriteable', 'univentionsharesobject', 'univentionsyntaxaddemptyvalue', 'univentionsyntaxdescription', 'univentionsyntaxldapattribute', 'univentionsyntaxldapbase', 'univentionsyntaxldapfilter', 'univentionsyntaxldapvalue', 'univentionsyntaxviewonly', 'univentionucsversionend', 'univentionucsversionstart', 'univentionudmoptiondefault', 'univentionudmoptioneditable', 'univentionudmoptionlongdescription', 'univentionudmoptionshortdescription', 'univentionudmoptiontranslationlongdescription', 'univentionudmoptiontranslationshortdescription', 'univentionudmpropertyaddemptyvalue', 'univentionudmpropertycliname', 'univentionudmpropertycopyable', 'univentionudmpropertydefault', 'univentionudmpropertydeleteobjectclass', 'univentionudmpropertydonotsearch', 'univentionudmpropertyhook', 'univentionudmpropertylayoutdisable', 'univentionudmpropertylayoutfullwidth', 'univentionudmpropertylayoutgroupname', 'univentionudmpropertylayoutgroupposition', 'univentionudmpropertylayoutoverwriteposition', 'univentionudmpropertylayoutoverwritetab', 'univentionudmpropertylayoutposition', 'univentionudmpropertylayouttabadvanced', 'univentionudmpropertylayouttabname', 'univentionudmpropertylongdescription', 'univentionudmpropertymultivalue', 'univentionudmpropertyoptions', 'univentionudmpropertyshortdescription', 'univentionudmpropertytranslationgroupname', 'univentionudmpropertytranslationlongdescription', 'univentionudmpropertytranslationshortdescription', 'univentionudmpropertytranslationtabname', 'univentionudmpropertyvaluemaychange', 'univentionudmpropertyvaluenoteditable', 'univentionudmpropertyvaluerequired', 'univentionumchelpdeskcategory', 'univentionusersobject', 'univentionvirtualmachineadvancedkernelconfig', 'univentionvirtualmachinecloudconnectiontyperef', 'univentionvirtualmachinecontact', 'univentionvirtualmachinedescription', 'univentionvirtualmachinegroup', 'univentionvirtualmachinemanageableby', 'univentionvirtualmachineos', 'univentionvirtualmachineprofilearch', 'univentionvirtualmachineprofilebootdevices', 'univentionvirtualmachineprofilecpus', 'univentionvirtualmachineprofilediskspace', 'univentionvirtualmachineprofiledrivercache', 'univentionvirtualmachineprofileinitramfs', 'univentionvirtualmachineprofileinterface', 'univentionvirtualmachineprofilekblayout', 'univentionvirtualmachineprofilekernel', 'univentionvirtualmachineprofilekernelparameter', 'univentionvirtualmachineprofilenameprefix', 'univentionvirtualmachineprofileos', 'univentionvirtualmachineprofilepvcdrom', 'univentionvirtualmachineprofilepvdisk', 'univentionvirtualmachineprofilepvinterface', 'univentionvirtualmachineprofileram', 'univentionvirtualmachineprofilertcoffset', 'univentionvirtualmachineprofileref', 'univentionvirtualmachineprofilevnc', 'univentionvirtualmachineprofilevirttech', 'univentionvirtualmachineuuid', 'univentionxautodetect', 'univentionxdisplayposition', 'univentionxdisplayprimary', 'univentionxdisplaysecondary', 'univentionxdisplaysize', 'univentionxdisplaysizechoices', 'univentionxdisplaysizesecondary', 'univentionxdisplayvirtualsize', 'univentionxhsync', 'univentionxhsyncchoices', 'univentionxhsyncsecondary', 'univentionxresolution', 'univentionxresolutionchoices', 'univentionxresolutionsecondary', 'univentionxvncexporttype', 'univentionxvncexportviewonly', 'univentionxvrefresh', 'univentionxvrefreshchoices', 'univentionxvrefreshsecondary', 'usessl', 'userclass', 'userid', 'virtualdomain', 'virtualdomainuser', 'zimbraaccountstatus', 'zimbraauthldapexternaldn', 'zimbracosid', 'zonename']) + if __name__ == '__main__': import doctest doctest.testmod()