|
37 |
import univention.admin |
37 |
import univention.admin |
38 |
import univention.admin.modules |
38 |
import univention.admin.modules |
39 |
import univention.admin.objects |
39 |
import univention.admin.objects |
40 |
import univention.admin.config |
|
|
41 |
import univention.admin.uldap |
40 |
import univention.admin.uldap |
42 |
import ldap |
41 |
import ldap |
43 |
from ldap.dn import escape_dn_chars |
42 |
from ldap.dn import escape_dn_chars |
|
49 |
"""Mass create users and groups.""" |
48 |
"""Mass create users and groups.""" |
50 |
|
49 |
|
51 |
def __init__(self, count): |
50 |
def __init__(self, count): |
52 |
# basic LDAP configuration |
|
|
53 |
self.config = univention.admin.config.config() |
54 |
|
55 |
# create LDAP connection |
51 |
# create LDAP connection |
56 |
self.access, self.position = univention.admin.uldap.getAdminConnection() |
52 |
self.access, self.position = univention.admin.uldap.getAdminConnection() |
57 |
|
53 |
|
|
76 |
|
72 |
|
77 |
def group(self, name, in_group=None): |
73 |
def group(self, name, in_group=None): |
78 |
"""Create group, which is itself member in_group.""" |
74 |
"""Create group, which is itself member in_group.""" |
79 |
g = self.gg.object(co=self.config, lo=self.access, position=self.gp) |
75 |
g = self.gg.object(co=None, lo=self.access, position=self.gp) |
80 |
g.options = ['posix', 'samba'] |
76 |
g.options = ['posix', 'samba'] |
81 |
g.open() |
77 |
g.open() |
82 |
g.info['name'] = name |
78 |
g.info['name'] = name |
|
97 |
def user(self, name, groups): |
93 |
def user(self, name, groups): |
98 |
"""Create user, which is itself member in groups.""" |
94 |
"""Create user, which is itself member in groups.""" |
99 |
gdn = ["cn=%s,%s" % (escape_dn_chars(group), self.gp.getDn()) for group in groups] |
95 |
gdn = ["cn=%s,%s" % (escape_dn_chars(group), self.gp.getDn()) for group in groups] |
100 |
u = self.uu.object(co=self.config, lo=self.access, position=self.up) |
96 |
u = self.uu.object(co=None, lo=self.access, position=self.up) |
101 |
# u.options = ['posix', 'samba'] |
97 |
# u.options = ['posix', 'samba'] |
102 |
u.open() |
98 |
u.open() |
103 |
u.info['username'] = name |
99 |
u.info['username'] = name |