3
#Copyright (C) 2007, 2008, 2009 usmteam
5
#This file is part of Ubuntu Server Manager
7
#This program is free software; you can redistribute it and/or
8
#modify it under the terms of the GNU General Public License
9
#as published by the Free Software Foundation; either version 2
10
#of the License, or (at your option) any later version.
12
#This program is distributed in the hope that it will be useful,
13
#but WITHOUT ANY WARRANTY; without even the implied warranty of
14
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
#GNU General Public License for more details.
17
#You should have received a copy of the GNU General Public License
18
#along with this program; if not, write to the Free Software
19
#Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21
#In addition, as a special exception, Oliver Marks gives permission to link
22
#the code of its release of usm with the OpenSSL project's "OpenSSL" library
23
#(or modified versions of the "OpenSSL" library that use the same license
24
#as the original version), and distribute the linked executables.
31
import ldap.modlist as modlist
34
from libs.v3.lib_plugins_helper import plugins
35
from libs.v3.lib_xml_data_form import forms
39
gettext.bindtextdomain('usm_directory', './lang/')
40
gettext.textdomain('usm_directory')
43
#info for building the debs
44
__debname__="usm-directory"
46
#space new line full stop for blank line
47
__debdescription__="""This Package Contains a plugin for managing a ldap directory service.\n"""
48
__debdepends__="python-ldap (>= 2.3.1), slapd (>= 2.4.9)"
52
#ldapsearch -x -s base (objectclass=*) namingContexts
53
#gui for brwsing directory gq
65
def group(self,name,desc="New Organizational unit / group"):
66
fpldif="dn: ou="+name+",o=domain-name\n"
67
fpldif+="ou: "+name+"\n"
68
fpldif+="objectClass: top\n"
69
fpldif+="objectClass: organizationalUnit\n"
70
fpldif+="description: "+desc+"\n"
73
def group_list(self,name,desc="New Organizational unit / group"):
75
#fpldif="dn: ou="+name+",o=domain-name\n"
77
fpldif["objectClass"]="top"
78
fpldif["objectClass"]="organizationalUnit"
79
fpldif["description"]=desc
82
def user_list(self,uid,fname,sname,password):
84
#dn: cn=John Doe, ou=Rochester, o=IBM, c=US
85
fpldif["objectclass"]=["person","inetOrgPerson","top","organizationalPerson","ePerson"]
86
fpldif["objectclass"]=["person","inetOrgPerson","top"]
87
fpldif["cn"]=fname+" "+sname
89
fpldif["uid"]=uid#"jdoe"
90
fpldif["userpassword"]=password #"secretpass"
94
class plugin(plugins):
95
plugin_name="usm_directory"
96
plugin_fold="usm_directory"
97
plugin_form="usm_directory.xml"
99
def __init__(self,core_globals):
100
plugins.__init__(self,globals=core_globals) #run __init__ method from plugins class instead of overridding
101
self.path_schema="/etc/ldap/schema/"
102
#/proc/sys/kernel/domainname for fqdn
103
fp=open("/proc/sys/kernel/hostname")
104
self.hostname=fp.read().strip("\n")
106
#self.load_ldif=from_ldif_file()
109
self.file_form=self.pluginpath+self.plugin_form
110
self.file_data=self.profilepath+"dns.xml"
111
self.ldap_group_ts=self.config.load_form(self.file_form,"group")
112
self.ldap_user_ts=self.config.load_form(self.file_form,"user")
118
self.server="127.0.0.1"
119
self.rootdn=self.get_basedn()
121
self.password=self.get_system_password()#"admin"#self.get_password()
122
#self.md5password=self.get_password().strip("\n")
123
print "slapd password = \"%s\"" % self.password
124
print "slappasswd -h {MD5} -s "+self.password
125
print "slappasswd -h {MD5} -s \"%s\"" % self.password
126
print commands.getstatusoutput("slappasswd -h {MD5} -s \"%s\"" % self.password)
127
self.md5password=commands.getstatusoutput("slappasswd -h {MD5} -s \"%s\"" % self.password)[1]
128
print "slapd password = "+self.md5password
129
self.admindn="cn=admin,"+self.rootdn
132
self.newldif=ldifcfg()
134
if not os.path.exists(self.configpath+"slapd.conf"):
135
self.generateconfig()
139
def index(self,form,web_page,globals={}):
140
xmlid=self.config.page(web_page,form)
141
htmout=plugins.index(self,form,web_page,globals=globals)
142
print self.get_basedn()
143
htmout+=self.setup_test()
145
#htmout+=plugins.index(self,form,web_page)
148
self.notify+=self.web.notifybox("No Base Domain have you setup your servers primary settings ?")
150
# self.directory = ldap.open(self.server)
151
# self.directory.simple_bind_s(self.admindn, self.password)
154
# self.notify+=self.web.successbox("Successsfully binded to ldap server")
156
# self.notify+= "Couldn't Connect. %s " % self.directory
158
htmout+=self.toolbar()
159
if self.web_page["subpage"]=="":
160
#htmout+=self.toolbar()
162
if self.web_page["action"]=="restart":
163
htmout+=self.page_restart()
165
if self.web_page["action"]=="newgroup":
166
#self.tagset2["config"]["iface"]["options"]=self.get_server_interfaces()
167
result,htm=self.config.handle_form(self.file_data+"mediatomb.xml")
169
#htmout+=self.newgroup(form)
171
if self.web_page["subpage"]=="groups":
172
if self.web_page["action"]=="form":
173
#self.tagset2["config"]["iface"]["options"]=self.get_server_interfaces()
175
htmout+=self.create_group(self.web_page["id"])
176
#htmout+=self.newgroup(form)
178
htmout+=self.show_groups()
180
if self.web_page["subpage"]=="users":
182
if self.web_page["action"]=="form":
183
#self.tagset2["config"]["iface"]["options"]=self.get_server_interfaces()
184
self.ldap_user_ts["config"]["group"]["options"]=self.list_groups()
185
result,htm=self.config.handle_form(self.ldap_user_ts)
187
htmout+=str(self.config.results)
191
#htmout+=self.newgroup(form)
192
htmout+=self.show_users()
194
if not self.check_process("slapd"):
195
self.notify+=self.web.notifybox("The slapd directopry Service is not running, try hitting restart icon above.")
197
if self.directory is not None:
202
return self.web.notify(self.notify)+htmout
204
def create_group(self,id=""):
205
id=id.replace("%3D","=")
207
print "got dn id what is it ?"
210
for record in self.finddn(id,("ou","description",)):
211
self.ldap_group_ts["config"]["name"]["values"]=record[1]["ou"][0]
212
self.ldap_group_ts["config"]["description"]["values"]=record[1]["description"][0]
213
print "get data from ldap"
217
result,htm=self.config.handle_form(self.ldap_group_ts)
219
htmout+=str(self.config.results)
223
dn="ou="+self.config.results["name"][1]+",ou=groups,"+self.rootdn
224
newrecord=self.newldif.group_list(self.config.results["name"][1],self.config.results["description"][1])
225
ldif = modlist.addModlist(newrecord)
226
htmout=self.add_ldif(dn,ldif)
229
def create_user(self):
231
dn="cn="+self.config.results["fname"][1]+" "+self.config.results["sname"][1]+",ou=groups,"+self.rootdn
232
newrecord=self.newldif.user_list(self.config.results["uid"][1],self.config.results["fname"][1],self.config.results["sname"][1],self.config.results["password"][1])
234
print "--------------------------------"
237
ldif = modlist.addModlist(newrecord)
238
htmout+=self.add_ldif(dn,ldif)
240
# print "connection opened"
241
# ldif = modlist.addModlist(newrecord)
242
# #htmout+=str(newrecord)
245
# self.directory.add_s(dn,ldif)
246
# except ldap.LDAPError, error_message:
247
# if error_message[0]["desc"]=="Already exists":
248
# htmout+=self.web.notifybox(_("Group Already Exists"))
249
# htmout+=str(error_message)
253
def search(self,filter,attributes):
255
dn="ou=groups,"+self.rootdn
259
print "connection opened"
262
ldap_result_id=self.directory.search(dn,ldap.SCOPE_SUBTREE,filter,attributes)
263
#print self.directory.result(ldap_result_id, 0)
264
#result_type, result_data = self.directory.result(ldap_result_id, 15)
266
result_type, result_data = self.directory.result(ldap_result_id, 5)
268
for result in result_data:
270
htmout+=self.web.boxrow(str(result))
272
except ldap.LDAPError, error_message:
273
if error_message[0]["desc"]=="Already exists":
274
htmout+=self.web.notifybox(_("Group Already Exists"))
275
htmout+=str(error_message)
279
def finddn(self,filter,attributes):
281
dn="ou=groups,"+self.rootdn
285
print "connection opened"
289
ldap_result_id=self.directory.search(filter,ldap.SCOPE_BASE,"objectclass=*",attributes)
290
#print self.directory.result(ldap_result_id, 0)
292
result_type, result_data = self.directory.result(ldap_result_id)
295
for result in result_data:
300
except ldap.LDAPError, error_message:
301
if error_message[0]["desc"]=="Already exists":
302
htmout+=self.web.notifybox(_("Group Already Exists"))
303
htmout+=str(error_message)
306
def find(self,filter,attributes):
308
dn="ou=groups,"+self.rootdn
312
print "connection opened"
315
ldap_result_id=self.directory.search(dn,ldap.SCOPE_SUBTREE,filter,attributes)
316
#print self.directory.result(ldap_result_id, 0)
317
#result_type, result_data = self.directory.result(ldap_result_id, 15)
319
result_type, result_data = self.directory.result(ldap_result_id, 5)
321
for result in result_data:
326
except ldap.LDAPError, error_message:
327
if error_message[0]["desc"]=="Already exists":
328
htmout+=self.web.notifybox(_("Group Already Exists"))
329
htmout+=str(error_message)
333
def add_ldif(self,dn,ldif):
336
print "connection opened"
339
print self.directory.add_s(dn,ldif)
340
except ldap.LDAPError, error_message:
343
if error_message[0]["desc"]=="Already exists":
344
htmout+=self.web.notifybox(_("Group Already Exists"))
345
htmout+=str(error_message)
349
def list_groups(self):
351
for r in self.find("ou=*",("ou","uniqueid",)):
353
list+=r[0]+"::"+r[1]["ou"][0]+"::::"
354
return list.rstrip("::::")
358
def show_groups(self):
359
htmout=self.web.container_start()
360
htmout+=self.search("ou=*",("ou",))
361
htmout+=self.web.container_end()
362
htmout=self.web.container_start()
363
for r in self.find("ou=*",("ou","description",)):
366
text=r[1]["ou"][0]+"<br />"
367
if "description" in r[1].keys():
368
text+=r[1]["description"][0]
369
button="<a href=\"index.py?Page="+self.web_page["page"]+"&subpage=groups&action=form&id="+ r[0].replace("=","%3D") +"\"><img alt=\"Edit\" src=\"/images/icons/silk/icons/table_edit.png\" />Modify Description</a><br />"
370
button+=self.web.but_img_confirm("index.py?Page="+self.web_page["page"]+"&subpage=groups&action=del&id="+ r[0].replace("=","%3D") ,"/images/icons/silk/icons/delete.png","Are You Sure you wish to delete this entry ?","Del")
371
htmout+=self.web.boxrow(text,right=button)
373
htmout+=self.web.container_end()
376
def show_users(self):
377
htmout=self.web.container_start()
378
htmout+=self.search("cn=*",("cn",))
380
htmout+=self.web.container_end()
383
htmout=self.web.container_start()
384
for r in self.find("cn=*",("cn","uid",)):
385
text=r[1]["cn"][0]+"<br />"+r[1]["uid"][0]
386
button="<a href=\"index.py?Page="+self.web_page["page"]+"&subpage=groups&action=form&id="+ r[0] +"\"><img alt=\"Edit\" src=\"/images/icons/silk/icons/table_edit.png\" />Modify Description</a><br />"
387
button+=self.web.but_img_confirm("index.py?Page="+self.web_page["page"]+"&subpage=groups&action=del&id="+ r[0] ,"/images/icons/silk/icons/delete.png","Are You Sure you wish to delete this entry ?","Del")
388
htmout+=self.web.boxrow(text,right=button)
390
htmout+=self.web.container_end()
393
def newgroup(self,form):
394
v=form_validate(self.web_page,self.ldap_group_ts,self.web)
395
result,htm=v.parse_form(form,self.ldap_group_ts)
400
#def group(self,name,desc="New Organizational unit / group"):
402
dn="ou="+v.results["name"]+","+self.rootdn
403
#newrecord['dn']="ou="+v.results["name"]+","+self.rootdn
404
newrecord['ou']=v.results["name"]
405
newrecord['objectclass']=['top','organizationalUnit']
406
newrecord['description']="test description"#v.results["description"]
409
ldif = modlist.addModlist(newrecord)
410
#htmout+=str(newrecord)
413
self.directory.add_s(dn,ldif)
414
except ldap.LDAPError, error_message:
415
if error_message[0]["desc"]=="Already exists":
416
htmout+=self.web.notifybox(_("Group Already Exists"))
417
htmout+=str(error_message)
421
#ldif="dn: ou="+name+",o=domain-name\n"
422
#ldif+="ou: "+name+"\n"
423
#ldif+="objectClass: top\n"
424
#ldif+="objectClass: organizationalUnit\n"
425
#ldif+="description: "+desc+"\n"
428
def addldif(self,newldif):
431
ldif = modlist.addModlist(newldif)
432
#htmout+=str(newrecord)
435
self.directory.add_s(dn,ldif)
436
except ldap.LDAPError, error_message:
437
if error_message[0]["desc"]=="Already exists":
438
htmout+=self.web.notifybox(_("Group Already Exists"))
439
htmout+=str(error_message)
443
def get_basedn_old(self):
445
path=(self.server_tagset["tagdepth"][0],self.hostname),
446
conf=self.server_config.get_config_dict(path,self.server_tagset)
448
for dc in conf["domain"].split("."):
450
domain=domain.rstrip(",")
457
print "ldap connect "
460
self.directory = ldap.open(self.server)
461
print "Connecting with %s and %s" % (self.admindn, self.password)
462
self.directory.simple_bind_s(self.admindn, self.password)
464
except ldap.LDAPError, error_message:
466
self.directory=error_message
470
self.directory.unbind_s()
473
tbar=self.web.tool_icon("index.py?Page="+self.web_page["page"]+"&SubPage=help","images/icons/tango/32x32/apps/help-browser.png","<b>Action: Help</b><br><i>Description: Help Documentation for this plugin module.</i>")
474
#tbar+=self.web.tool_icon("index.py?Page="+self.web_page["page"]+"&SubPage=form_share","images/icons/tango/32x32/places/folder-remote.png","<b>Action: New Share</b><br><i>Description: Add New Shared Folder</i>")
475
tbar+=self.web.tool_icon("index.py?Page="+self.web_page["page"]+"&SubPage=log","images/icons/tango/32x32/categories/preferences-desktop.png","<b>Action: Log files</b><br><i>Description: View your samba log files.</i>")
476
tbar+=self.web.tool_icon("index.py?Page="+self.web_page["page"]+"&subpage=groups&action=form","images/icons/tango/32x32/apps/preferences-desktop-theme.png","<b>Action: Add New Group</b><br><i>Description: Add a new group to the directory.</i>")
477
tbar+=self.web.tool_icon("index.py?Page="+self.web_page["page"]+"&subpage=users&action=form","images/icons/tango/32x32/apps/system-users.png","<b>Action: Add New User</b><br><i>Description: Create a new account for a person.</i>")
478
tbar+=self.web.tool_icon("index.py?Page="+self.web_page["page"]+"&action=restart","images/icons/tango/32x32/actions/view-refresh.png","<b>Action: Restart</b><br><i>Description: Restart samba service</i>")
479
return self.web.tool_bar("Shared Network Folders Configuration",tbar)
481
def page_default(self):#if any zones exist display them in a table
482
htmout=self.toolbar()
484
#htmout+=self.web.table_start("Shared Network Folders",("N","Folder","Path","Comments","Modify"))
486
#for share in self.config.get_list(self.tagset3):
487
# path=(self.tagset3["tagdepth"][0],share),
488
# conf=self.config.get_config_dict(path,self.tagset3)
489
# style=self.web.switch_style(style,"tabrow1","tabrow2")
490
# htmout+="<tr class=\""+style+"\"><td >" + str(count) + "</td>"
491
# htmout+="<td><a href=\"index.py?Page=Shares&SubPage=form_share&name="+ str(share) +"\">" + str(share) + "</a></td>"
492
# htmout+="<td>" + conf["path"] + "</td>"
493
# htmout+="<td>" + conf["comments"] + "</td>"
495
# htmout+=self.web.but_img("index.py?Page="+self.web_page["page"]+"&SubPage=form_share&name="+ str(share),"/images/icons/silk/icons/table_edit.png","Edit")
496
# htmou:t+=self.web.but_img_confirm("index.py?Page="+self.web_page["page"]+"&SubPage=del_share&name="+ share,"/images/icons/silk/icons/delete.png","Are You Sure you wish to remove this share, this will not remove your files and will only disable the sharing of this folder ?","Del")
497
# htmout+="</td></tr>"
499
#htmout+=self.web.table_end()+"<br />"
502
def page_broadcast(self):
503
xml="<service name=\"shares\">"
504
xml+="<win exe=\"explorer.exe\">\\\\</win>"
505
xml+="<gnome exe=\"nautilus\">smb://</gnome>"
507
self.load_config_file(self.profilepath,"customshares.xml","shares")
508
items = self.doc.getSubTagAttrib(self.tagset3["tagdepth"][0])
510
xml+="<item name=\""+item+"\">"+item+"</item>"
514
def get_password(self):
515
fp = open(self.path+"security/users/.usmpasswd")
517
for line in fp.readlines():
519
if sp[0]=="usmadmin":
524
def setup_test(self):
527
#scope=ldap.SCOPE_SUBTREE
530
result_id = self.directory.search(self.rootdn,ldap.SCOPE_ONELEVEL,"objectclass=*")
531
rt,rd=self.directory.result(result_id)
539
def inital_ldap(self):
540
#add root dn object for our domain
544
dc=self.rootdn.split(",")[0]
546
fpldif="dn: "+self.rootdn+"\n"
547
fpldif+="objectclass: dcObject\n"
548
fpldif+="objectclass: organization\n"
549
fpldif+="o: example\n"
550
fpldif+="dc: "+dc.split("dc=")[1]+"\n\n"
553
fpldif+="dn: cn=admin,"+self.rootdn+"\n"
554
fpldif+="objectclass: organizationalRole\n"
555
fpldif+="cn: admin\n\n"
557
fpldif+="dn: ou=groups,"+self.rootdn+"\n"
558
fpldif+="ou: groups\n"
559
fpldif+="objectclass: top\n"
560
fpldif+="objectclass: organizationalUnit\n"
561
fpldif+="description: group for users\n\n"
563
fpldif+="dn: ou=users,"+self.rootdn+"\n"
564
fpldif+="ou: users\n"
565
fpldif+="objectclass: top\n"
566
fpldif+="objectclass: organizationalUnit\n"
567
fpldif+="description: group for groups\n\n"
569
fpldif+="dn: ou=address book,"+self.rootdn+"\n"
570
fpldif+="ou: address book\n"
571
fpldif+="objectclass: top\n"
572
fpldif+="objectclass: organizationalUnit\n"
573
fpldif+="description: Address Book\n\n"
575
self.save_config(self.configpath+"base.ldif",fpldif)
576
fp=open(self.configpath+"base.ldif")
579
for r in from_ldif_file(fp).results:
581
htmout+=str(r)+"<br /><br />"
582
htmout+="Inital ldap connection and base ldif import"
583
print "Inital ldap connection and base ldif import"
586
htmout+="Inital Ldap setup"
587
htmout+=str(ldif_entry)
589
self.directory.add_s(dn,ldif_entry)
590
except ldap.LDAPError, error_message:
591
#if error_message[0]["desc"]=="Already exists":
592
# htmout+=self.web.notifybox(_("Group Already Exists"))
594
htmout+=str(error_message)
597
htmout+=str(self.directory)
604
def slapd_dbconfig(self):
606
slapd_db.append("dn: olcDatabase={1}bdb\n")
607
slapd_db.append("objectClass: olcDatabaseConfig\n")
608
slapd_db.append("objectClass: olcBdbConfig\n")
609
slapd_db.append("olcDatabase: {1}bdb\n")
610
slapd_db.append("olcSuffix: %s\n" % self.rootdn)
611
slapd_db.append("olcLastMod: TRUE\n")
612
slapd_db.append("olcMaxDerefDepth: 15\n")
613
slapd_db.append("olcReadOnly: FALSE\n")
614
slapd_db.append("olcRootDN: %s\n" % self.admindn)
615
slapd_db.append("olcRootPW: %s\n" % self.md5password)
616
slapd_db.append("olcMonitoring: FALSE\n")
617
slapd_db.append("olcDbDirectory: /var/lib/ldap\n")
618
slapd_db.append("olcDbCacheSize: 1000\n")
619
slapd_db.append("olcDbConfig: {0}set_cachesize 0 2097152 0\n")
620
slapd_db.append("olcDbConfig: {1}set_lk_max_objects 1500\n")
621
slapd_db.append("olcDbConfig: {2}set_lk_max_locks 1500\n")
622
slapd_db.append("olcDbConfig: {3}set_lk_max_lockers 1500\n")
623
slapd_db.append("olcDbNoSync: FALSE\n")
624
slapd_db.append("olcDbDirtyRead: FALSE\n")
625
slapd_db.append("olcDbIDLcacheSize: 0\n")
626
slapd_db.append("olcDbIndex: objectClass eq\n")
627
slapd_db.append("olcDbLinearIndex: FALSE\n")
628
slapd_db.append("olcDbMode: 384\n")
629
slapd_db.append("olcDbSearchStack: 16\n")
630
slapd_db.append("olcDbShmKey: 0\n")
631
slapd_db.append("olcDbCacheFree: 1\n")
632
slapd_db.append("olcDbDNcacheSize: 0\n")
633
slapd_db.append("structuralObjectClass: olcBdbConfig\n")
634
slapd_db.append("entryUUID: e5e558da-2edc-102d-8361-c3a44ea1fbdf\n")
635
slapd_db.append("creatorsName: cn=config\n")
636
slapd_db.append("createTimestamp: 20081015081331Z\n")
637
slapd_db.append("entryCSN: 20081015081331.155160Z#000000#000#000000\n")
638
slapd_db.append("modifiersName: cn=config\n")
639
slapd_db.append("modifyTimestamp: 20081015081331Z\n")
641
self.save_config(self.configpath+"olcDatabase={1}bdb.ldif","".join(slapd_db))
642
self.run("copy_config|"+self.configpath+"olcDatabase={1}bdb.ldif|/etc/ldap/slapd.d/cn=config/olcDatabase={1}bdb.ldif")
644
def generateconfig(self):#if any zones exist display them in a table
645
#we have to update the ldap apparmor profile to allow creation of multiple databases
646
self.run("apparmor_profile|"+self.pluginpath+"usr.sbin.slapd|usr.sbin.slapd")
647
self.run("slapd_db|/var/lib/ldap/%s" % self.domain)
649
self.slapd_dbconfig()
651
conf="#test file with slaptest "
652
conf+="#######################################################################\n"
653
conf+="# Global Directives:\n"
655
conf+="include "+self.path_schema+"core.schema\n"#required
656
conf+="include "+self.path_schema+"cosine.schema\n"#Recomended: Cosine, Internet X.500
657
conf+="include "+self.path_schema+"inetorgperson.schema\n"#Recomended
658
conf+="include "+self.path_schema+"nis.schema\n\n"#NIS (Network Information Services), Sun NFS support.
660
conf+="allow bind_v2\n"
661
conf+="pidfile /var/run/slapd/slapd.pid\n"
662
conf+="argsfile /var/run/slapd/slapd.args\n"
663
conf+="loglevel 1\n"#none
664
conf+="modulepath /usr/lib/ldap/\n"
665
conf+="moduleload back_bdb\n\n"
667
conf+="# Save the time that the entry gets modified, for database #1\n"
668
conf+="lastmod on\n\n"
670
conf+="# The maximum number of entries that is returned for a search operation\n"
671
conf+="sizelimit 500\n\n"
673
#conf+="access to attrs=userPassword\n"
674
#conf+="\tby dn=\"uid=root,ou=People,"+self.rootdn+"\" write\n"
675
#conf+="\tby dn=\""+self.admindn+"\" write\n"
676
#conf+="\tby anonymous auth\n"
677
#conf+="\tby self write\n"
678
#conf+="\tby * none\n\n"
680
conf+="# The admin dn has full write access, everyone else\n"
681
conf+="# can read everything.\n"
682
conf+="access to dn.base=\"\" by * read\n"
683
conf+="access to *\n"
684
conf+="\tby dn=\""+self.admindn+"\" write\n"
685
conf+="\tby * read\n\n"
688
conf+="database\tbdb\n"
689
#slapd apparmour profile is in /etc/apparmor.d/usr.sbin.slapd
690
#to create folders inside /var/lib/ldap need to modify apparmour as it protects the path
691
conf+="directory /var/lib/ldap/%s\n" % self.domain
692
#conf+="directory /var/lib/ldap/\n"
693
conf+="suffix\t\""+self.rootdn+"\"\n"
694
conf+="rootdn\t\""+self.admindn+"\"\n"#for replication
695
conf+="rootpw\t"+self.md5password+"\n\n"#needs {md5} or other type
698
conf+="index objectClass eq\n\n"
699
print "regenerate new config"
701
self.save_config(self.configpath+"slapd.conf",conf)
702
self.run("copy_config|"+self.configpath+"slapd.conf|/etc/ldap/slapd.conf")
708
def page_restart(self):
709
htm=self.generateconfig()
710
self.run_background("restart|slapd")
713
#class get_groups(self):
719
class from_ldif_file(ldif.LDIFParser):
721
def __init__(self,txt):
722
ldif.LDIFParser.__init__(self,txt,None,0,None,"\n")
726
def handle(self,dn,entry):
729
#ldif = modlist.addModlist(newldif)
730
self.results+=(dn,modlist.addModlist(entry)),