summaryrefslogtreecommitdiffstats
path: root/doc/sample-insert-hosted-user_types.php
blob: 3485865742803883fa6daee8eac3a1d279e8072e (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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
#!/usr/bin/php
<?php

    if (isset($_SERVER["REQUEST_METHOD"]) && !empty($SERVER["REQUEST_METHOD"])) {
        die("Not intended for execution through the webserver, sorry!");
    }

    require_once("lib/functions.php");

    $db   = SQL::get_instance();

    $result = $db->query("TRUNCATE TABLE `user_types`");

    $attributes = Array(

            /*
             * The form fields for which the values can be
             * generated automatically, using the existing
             * values of form_fields
             */
            "auto_form_fields" => Array(
                    /*
                     * The 'cn' attribute is required for
                     * the LDAP objectclasses we use, but
                     * can be composed from a 'givenname'
                     * and 'sn' attribute form_field (of
                     * which 'sn' is also a required
                     * attribute.
                     */
                    "cn" => Array(
                            "data" => Array(
                                    "givenname",
                                    "sn",
                                ),
                        ),
                    /*
                     * The 'mail' attribute is supposed to 
                     * contain the email address this user
                     * will use for this environment, and
                     * is (supposed?) to match the 'uid'
                     * for the user account.
                     *
                     * Disable this auto_form_field if
                     * the API is not capable of making
                     * a 'uid' become a 'uid'@'domain',
                     * where 'domain' is not a valid
                     * LDAP attribute for a user entry.
                     */
                    "mail" => Array(
                            "data" => Array(
                                    "uid",
                                ),
                        ),
                ),
            "form_fields" => Array(
                    /*
                     * Givenname is a requirement, but could
                     * be filled with random data if not
                     * wanted.
                     */
                    "givenname" => Array(),
                    /*
                     * The 'mailalternateaddress' is supposed
                     * to contain the original email address
                     * for the user.
                     */
                    "mailalternateaddress" => Array(
                            "optional" => true,
                        ),
                    "sn" => Array(),
                    "uid" => Array(),
                    "userpassword" => Array(
                            "type" => "password",
//                            "optional" => true,
                        ),
                ),
            "fields" => Array(
                    "mailquota" => "131072",
                    "nsroledn" => "cn=personal-user,dc=notifytest,dc=tld",
                    "objectclass" => Array(
                            "top",
                            "inetorgperson",
                            "kolabinetorgperson",
                            "mailrecipient",
                            "organizationalperson",
                            "person",
                        ),
                ),
        );

    $result = $db->query("INSERT INTO `user_types` (`key`, `name`, `description`, `attributes`, `used_for`) " .
                "VALUES ('personal','Personal', 'A user with a personal hosted plan'," .
                "'" . json_encode($attributes) . "', 'hosted')");

    $attributes = Array(
            /*
             * The form fields for which the values can be
             * generated automatically, using the existing
             * values of form_fields
             */
            "auto_form_fields" => Array(
                    /*
                     * The 'cn' attribute is required for
                     * the LDAP objectclasses we use, but
                     * can be composed from a 'givenname'
                     * and 'sn' attribute form_field (of
                     * which 'sn' is also a required
                     * attribute.
                     */
                    "cn" => Array(
                            "data" => Array(
                                    "givenname",
                                    "sn",
                                ),
                        ),
                    /*
                     * The 'mail' attribute is supposed to 
                     * contain the email address this user
                     * will use for this environment, and
                     * is (supposed?) to match the 'uid'
                     * for the user account.
                     *
                     * Disable this auto_form_field if
                     * the API is not capable of making
                     * a 'uid' become a 'uid'@'domain',
                     * where 'domain' is not a valid
                     * LDAP attribute for a user entry.
                     */
                    "mail" => Array(
                            "data" => Array(
                                    "uid",
                                ),
                        ),
                ),
            "form_fields" => Array(
                    "alias" => Array(
                            "type" => "list",
                            "optional" => true,
                            "maxcount" => 2,
                        ),
                    /*
                     * Givenname is a requirement, but could
                     * be filled with random data if not
                     * wanted.
                     */
                    "givenname" => Array(),
                    /*
                     * The 'mailalternateaddress' is supposed
                     * to contain the original email address
                     * for the user.
                     */
                    "mailalternateaddress" => Array(
                            "optional" => true,
                        ),
                    "sn" => Array(),
                    "uid" => Array(),
                    "userpassword" => Array(
                            "type" => "password",
//                            "optional" => true,
                        ),
                ),
            "fields" => Array(
                    "mailquota" => "1048576",
                    "nsroledn" => "cn=professional-user,dc=notifytest,dc=tld",
                    "objectclass" => Array(
                            "top",
                            "inetorgperson",
                            "kolabinetorgperson",
                            "mailrecipient",
                            "organizationalperson",
                            "person",
                        ),
                ),
        );

    $result = $db->query("INSERT INTO `user_types` (`key`, `name`, `description`, `attributes`, `used_for`) " .
                "VALUES ('professional','Professional', 'A user with a professional hosted plan'," .
                "'" . json_encode($attributes) . "', 'hosted')");

?>