Esempio n. 1
0
    def create_access(self):
        user_mail = self.conf.get('main','client_mail')

        unix_user = self.conf.get('access','unix_user')
        unix_pass = self.conf.get('access','unix_pass')
        unix_group = self.conf.get('access','unix_group')

        ldap_user = self.conf.get('access','ldap_user')
        ldap_pass = self.conf.get('access','ldap_pass')
        ldap_group = self.conf.get('access','ldap_group')

        if CONF_MAP('ldap','enabled') and self.conf.get('access','ldap_to_apply'):
            self.ask_domain_admin()
            if ldap_user and not ldap.user_exists(ldap_user):
                ldap.create_user(ldap_user, user_mail, ldap_pass)
            if ldap_group and not ldap.group_exists(ldap_group):
                ldap.create_group(ldap_group)
            if ldap_user and ldap_group and not ldap.is_member_of(ldap_user, ldap_group):
                ldap.user_to_group(ldap_user, ldap_group)

        if CONF_MAP('unix','enabled'):
            if unix_user and not unix.user_exists(unix_user):
                unix.create_user(unix_user, user_mail, unix_pass)
            if unix_group and not unix.group_exists(unix_group):
                unix.create_group(unix_group)
            if unix_user and unix_group and not unix.is_member_of(unix_user , unix_group):
                unix.user_to_group(unix_user, unix_group)
Esempio n. 2
0
    def ask_create_access(self):
        safe_site_name = self.get_safe_name(self.conf.get('main','site_name'))

        unix_user = self.conf.get('access','unix_user')
        unix_group = self.conf.get('access','unix_group')
        #ldap_user = self.conf.get('access','ldap_user')
        ldap_group = self.conf.get('access','ldap_group')
        ldap_to_apply = False

        if unix_group is None:
            unix_group = safe_site_name + "_unix"

        if ldap_group is None:
            ldap_group = safe_site_name

        #TODO not working for now. Needs debug
        #if CONF_MAP('ldap','enabled') and inputs.get_input_noyes(t("Do you want to create a LDAP user?")):
        #    ldap_user = self.ask_create_user(ldap_user)
        #    self.conf.mod('access','ldap_user', ldap_user)
        #    if ldap_user and not ldap.user_exists(ldap_user):
        #        self.conf.mod('access','ldap_pass', inputs.gen_password())
        #    ldap_to_apply = True

        if CONF_MAP('ldap','enabled') and inputs.get_input_yesno(t("Do you want to create a LDAP group?")):
            self.conf.mod('access','ldap_group', self.ask_create_group(ldap_group))
            ldap_to_apply = True

        if CONF_MAP('unix','enabled') and inputs.get_input_yesno(t("Do you want to create a UNIX user?")):
            unix_user = self.ask_create_user(unix_user)
            self.conf.mod('access','unix_user', unix_user)
            if unix_user and not unix.user_exists(unix_user):
                self.conf.mod('access','unix_pass', inputs.gen_password(allowed_chars=inputs.PASS_CHARS_UNIX))

        if CONF_MAP('unix','enabled') and inputs.get_input_yesno(t("Do you want to create a UNIX group?")):
            self.conf.mod('access','unix_group', self.ask_create_group(unix_group))

        self.conf.mod('access','ldap_to_apply',ldap_to_apply)