1 (edited by murat.ugur 2011-02-01 17:01:19)

Topic: Split Usernames ?

Dear all, i have iredmail opensource. I want to split usernames,

For example;
Normal split => m/mu/mur/murat.ugur-2011.01.21.12.49.34/

How i can split more ?

how i can split 6 character ? we use iredadmin panel. Which i can change file ?

maybe, m/mu/mur/mura/murat/murat.ugur-2011.01.21.12.49.34/ 

where i can change ?

def ldif_mailuser(domain, username, cn, passwd, quota=cfg.general.get('default_quota')):
    DATE = time.strftime('%Y.%m.%d.%H.%M.%S')
    domain = str(domain).lower()
    quota = int(quota) * 1024 * 1024
    username = ldaputils.removeSpaceAndDot(str(username)).lower()
    mail = username + '@' + domain
    #dn = convEmailToUserDN(mail)

    if eval(cfg.general.get('hashed_maildir', True)) is True:
        if len(username) >= 3:
            maildir_user = "%s/%s/%s/%s-%s/" % (username[:1], username[:2], username[:3], username, DATE,)
        elif len(username) == 2:
            maildir_user = "%s/%s/%s/%s-%s/" % (
                    username[:1],
                    username[:],
                    username[:] + username[-1],
                    username,
                    DATE,
                    )
        else:
            maildir_user = "%s/%s/%s/%s-%s/" % (
                    username[0],
                    username[0] * 2,
                    username[0] * 3,
                    username,
                    DATE,
                    )
        mailMessageStore = domain + '/' + maildir_user
    else:
        mailMessageStore = "%s/%s-%s/" % (domain, username, DATE,)

    mailMessageStore =  cfg.general.get('storage_node').lower() + '/' + mailMessageStore.lower()
    storageBaseDirectory = cfg.general.get('storage_base_directory').lower()
    homeDirectory = storageBaseDirectory + '/' + mailMessageStore

    ldif = [
        ('objectClass',         ['inetOrgPerson', 'mailUser', 'shadowAccount', 'amavisAccount',]),
        ('mail',                [mail]),
        ('userPassword',        [str(passwd)]),
        ('mailQuota',           [str(quota)]),
        ('sn',                  [username]),
        ('uid',                 [username]),
        ('storageBaseDirectory', [storageBaseDirectory]),
        ('mailMessageStore',    [mailMessageStore]),
        ('homeDirectory',       [homeDirectory]),
        ('accountStatus',       ['active']),
        ('mtaTransport',        ['dovecot']),
        ('enabledService',      ['mail', 'smtp', 'deliver',
                                 'pop3', 'pop3secured', 'imap', 'imapsecured',
                                 'managesieve', 'managesievesecured',
                                 'sieve', 'sievesecured', 'internal',
                                 'forward', 'senderbcc', 'recipientbcc',
                                 'shadowaddress', 'displayedInGlobalAddressBook', ]),
        ]

    ldif += ldaputils.getSingleLDIF(attr='cn', value=cn, default=username)

    return ldif

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: Split Usernames ?

solved;

if len(username) >= 6:
            maildir_user = "%s/%s/%s/%s/%s/%s/%s-%s/" % (username[:1], username[:2], username[:3],username[:4],username[:5],username[:6], username, DATE,)