summaryrefslogtreecommitdiffstats
path: root/ipalib/plugins/config.py
blob: 3030ce7c7befb1bf536490396d4a108d345d01d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# Authors:
#   Rob Crittenden <rcritten@redhat.com>
#   Pavel Zuna <pzuna@redhat.com>
#
# Copyright (C) 2008  Red Hat
# see file 'COPYING' for use and warranty information
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; version 2 only
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
"""
IPA configuration
"""

from ipalib import api
from ipalib import Bool, Int, Str
from ipalib.plugins.baseldap import *


class config(LDAPObject):
    """
    IPA configuration object
    """
    object_name = 'configuration options'
    default_attributes = [
        'ipamaxusernamelength', 'ipahomesrootdir', 'ipadefaultloginshell',
        'ipadefaultprimarygroup', 'ipadefaultdomain', 'ipasearchtimelimit',
        'ipasearchrecordslimit', 'ipausersearchfields', 'ipagroupsearchfields',
        'ipamigrationenabled',
    ]
    attribute_names = {
        'ipamaxusernamelength': 'maximum username length',
        'ipahomesrootdir': 'root of home directories',
        'ipadefaultloginshell': 'default login shell',
        'ipadefaultprimarygroup': 'default primary group',
        'ipadefaultdomain': 'default e-mail domain',
        'ipasearchtimelimit': 'time limit for search queries',
        'ipasearchrecordslimit': 'result count limit for search queries',
        'ipausersearchfields': 'search fields for users',
        'ipagroupsearchfields': 'search fields for groups',
        'ipamigrationenabled': 'enable migration mode',
    }

    takes_params = (
        Int('ipamaxusernamelength?',
            cli_name='maxusername',
            doc='Max. Username length',
            minvalue=1,
        ),
        Str('ipahomesrootdir?',
            cli_name='homedirectory',
            doc='Default location of home directories',
        ),
        Str('ipadefaultloginshell?',
            cli_name='defaultshell',
            doc='Default shell for new users',
        ),
        Str('ipadefaultprimarygroup?',
            cli_name='defaultgroup',
            doc='Default group for new users',
        ),
        Str('ipadefaultemaildomain?',
            cli_name='emaildomain',
            doc='Default e-mail domain new users',
        ),
        Int('ipasearchtimelimit?',
            cli_name='searchtimelimit',
            doc='Max. amount of time (sec.) for a search (-1 is unlimited)',
            minvalue=-1,
        ),
        Int('ipasearchrecordslimit?',
            cli_name='searchrecordslimit',
            doc='Max. number of records to search (-1 is unlimited)',
            minvalue=-1,
        ),
        Str('ipausersearchfields?',
            cli_name='usersearch',
            doc='A comma-separated list of fields to search when searching for users',
        ),
        Str('ipagroupsearchfields?',
            cli_name='groupsearch',
            doc='A comma-separated list of fields to search when searching for groups',
        ),
        Bool('ipamigrationenabled?',
            cli_name='enable_migration',
            doc='Enabled migration mode',
        ),
    )

    def get_dn(self, *keys, **kwargs):
        return 'cn=ipaconfig,cn=etc'

api.register(config)


class config_mod(LDAPUpdate):
    """
    Modify configuration options.
    """
    def pre_callback(self, ldap, dn, entry_attrs, attrs_list, *keys, **options):
        if 'ipamigrationenabled' in entry_attrs:
            if entry_attrs['ipamigrationenabled']:
                entry_attrs['ipamigrationenabled'] = 'TRUE'
            else:
                entry_attrs['ipamigrationenabled'] = 'FALSE'
        return dn

api.register(config_mod)


class config_show(LDAPRetrieve):
    """
    Display configuration options.
    """

api.register(config_show)