54
54
# setup /etc/nsswitch.conf (libnss_winbind for passwd & group)
57
def gtk_config(self, container, domain, params, func_config_changed=None):
57
def gtk_config(self, container, domain_entry, params, func_config_changed=None):
58
58
"""Draw own config UI into the supplied container"""
63
63
for widget in kids:
64
64
container.remove(widget)
66
domain = domain.get_text()
66
self.domain = domain_entry.get_text()
67
67
# detect if host is already in configured domain
68
if self.check_join_status(domain, params):
68
if (params.has_key('skip_join') and params['skip_join'] == True) and self.check_join_status(params):
70
tb = gtk.Table(rows=4, columns=2)
71
info_hb = gtk.HBox(False, 1)
72
info_img = gtk.Image()
73
info_img.set_from_stock( gtk.STOCK_NETWORK,gtk.ICON_SIZE_DIALOG)
75
info_label = gtk.Label("Enter the settings for your Active Directory configuration")
76
info_label.set_line_wrap(True)
77
info_hb.pack_start(info_img)
78
info_hb.pack_start(info_label)
81
wkgrp_label = gtk.Label("Workgroup")
82
wkgrp_entry = gtk.Entry(60)
83
wkgrp_entry = gtk.Entry(60)
86
tb.attach(info_hb, 0, 2, 0, 1)
87
tb.attach(wkgrp_label, 0, 1, 1, 2)
88
tb.attach(wkgrp_entry, 1, 2, 1, 2)
89
container.pack_start(tb)
91
#Try & use the boring default
92
authtools.IAuthConfig.gtk_config(self, container, domain_entry, params, func_config_changed)
104
125
join_img.set_from_stock( gtk.STOCK_CONNECT, gtk.ICON_SIZE_BUTTON)
105
126
join_btn.set_image( join_img )
107
params = {'domain':domain, 'user':admin_entry, 'passwd':passwd_entry}
108
join_btn.connect('clicked', self.gtk_join, params)
128
join_params = {'domain':self.domain, 'user':admin_entry, 'passwd':passwd_entry,'container':container, 'domain_entry':domain_entry,'changed':func_config_changed, 'params': params }
129
join_btn.connect('clicked', self.gtk_join, join_params)
109
130
join_hb.pack_start(join_btn, expand=False, fill=False, padding=6)
112
container.add(join_hb)
132
container.pack_start(tb)
133
container.pack_start(join_hb)
114
135
container.show_all()
117
def check_join_status(self, domain, params):
138
def check_join_status(self, params):
118
139
"""Check with 'net ads' whether the system is joined to the domain
141
# bypass this pile for now
144
import os, subprocess
145
realm = self.domain.upper()
146
print "Testing join with realm %s" % realm
147
wb = self.at.get_method_obj('Winbind')
149
if params.has_key('user') and params['user'] != '':
150
user = "-U %s%%%s" % (params['user'], params['passwd'])
154
smb_conf = wb.skeleton_conf( {'global':{'security':'ads','workgroup':self.domain,'realm':realm}})
156
r = os.system("net ads testjoin -s %s %s" % smb_conf.name, user)
158
print "Machine is in domain"
122
163
def gtk_join(self, widget, params):
123
164
"""Wrapper for the generic join method"""
124
self.join(params['domain'],
165
self.join(self.domain,
125
166
{'user': params['user'].get_text(),
126
167
'passwd': params['passwd'].get_text()
171
params['params']['skip_join'] = True
172
#print params['domain_entry']
173
self.gtk_config(params['container'], params['domain_entry'], params['params'], params['changed'])
130
175
def join(self, domain, params):
131
176
"""By request, this needs to handle joining sub-OUs with
140
185
if params.has_key('user') and params['user'] != '':
141
user = "-U %s" % params['user']
186
user = "-U %s%%%s" % (params['user'], params['passwd'])
146
os.system("net ads join %s" % user)
188
#dummy password to stop UI blocking
148
191
# get a handle on the winbind auth method, so we can play with it
149
192
wb = self.at.get_method_obj('Winbind')
194
# Create a new config file with 'security=ads', workgroup=domain and 'realm=domain'
195
realm = domain.upper()
196
smb_conf = wb.skeleton_conf( {'global':{'security':'ads','workgroup':domain,'realm':realm}})
197
print "net ads join -s %s %s" % (smb_conf.name, user)
198
os.system("net ads join -s %s %s" % (smb_conf.name, user))
151
201
def detect(self, params):
152
202
# does this params['domain'] match a kerberos service?