diff --git a/creolefuncs/lemonldap.py b/creolefuncs/lemonldap.py index 900c541..c68c218 100644 --- a/creolefuncs/lemonldap.py +++ b/creolefuncs/lemonldap.py @@ -26,3 +26,41 @@ def readPass(encoder,reader): except: return "mot de passe inconnu" + +def getSSOFilters(): + """ Convert former eole-sso filters to LemonLDAP filters + """ + import glob + from ConfigParser import ConfigParser + import json + try: + filters = {} + filterDirectory = "/usr/share/sso/app_filters/" + filterExtention = ".ini" + filterSection = "utilisateur" + filterFiles = glob.glob("{0}/*{1}".format(filterDirectory, filterExtention)) + toClean = ["uid","mail","cn","__name__"] + for fi in filterFiles: + # Don't parse "applications.ini" + config = ConfigParser() + config.read(fi) + if filterSection in config._sections: + filters.update(config._sections[filterSection].items()) + + for key in toClean: + del(filters[key]) + + res = "" + index=0 + size=len(filters) + for k,v in filters.items(): + res += " \"{0}\": \"{1}\",".format(k,v) + index += 1 + if index != size: + res += "\n" + + return(res) + + except: + return "Error Generating Filters" + diff --git a/tmpl/lmConf-1.js b/tmpl/lmConf-1.js index 35d9a14..7617c34 100644 --- a/tmpl/lmConf-1.js +++ b/tmpl/lmConf-1.js @@ -160,6 +160,7 @@ "ldapPpolicyControl": 0, "casAttributes": { "uid":"uid", +%%getSSOFilters %for att in %%casAttribute "%%att": "%%att.casLDAPAttribute", %end for