Example #1
0
def setup():
    global conn
    conn = DSAdmin(**config.auth)
    conn.verbose = True
    conn.added_entries = []
    conn.added_backends = set(['o=mockbe2'])
    conn.added_replicas = []
    harn_nolog()
Example #2
0
def setup():
    global conn
    try:
        conn = DSAdmin(**config.auth)
        conn.verbose = True
        conn.added_entries = []
    except SERVER_DOWN, e:
        log.error("To run tests you need a working 389 instance %s" %
                  config.auth)
        raise e
def default_test():
    host = 'localhost'
    port = 10200
    binddn = "cn=directory manager"
    bindpw = "password"
    suffix = 'dc=example,dc=com'
    basedn = DN_CONFIG
    scope = ldap.SCOPE_BASE
    filt = "(objectclass=*)"
    instance_name = ['m1', 'm2']

    instance_config = {
        'cfgdshost': host,
        'cfgdsport': port,
        'cfgdsuser': '******',
        'cfgdspwd': 'admin',
        'newrootpw': 'password',
        'newhost': host,
        'newport': port,
        'newinstance': instance_name[0],
        'newsuffix': suffix,
        'setup_admin': True,
    }
    try:
        m1 = DSAdmin(host, port, binddn, bindpw)
    except:
        m1 = DSAdminTools.createInstance(instance_config, verbose=1)
        added_instances.append(instance_config['newinstance'])

#        filename = "%s/slapd-%s/ldif/Example.ldif" % (m1.sroot, m1.inst)
#        m1.importLDIF(filename, "dc=example,dc=com", None, True)
#        m1.exportLDIF('/tmp/ldif', "dc=example,dc=com", False, True)
    print m1.sroot, m1.inst, m1.errlog
    ent = m1.getEntry(basedn, scope, filt, None)
    if ent:
        print ent.passwordmaxage
    instance_config.update({
        'newinstance': instance_name[1],
        'newport': port + 10,
    })
    m1 = DSAdminTools.createInstance(instance_config, verbose=1)
    added_instances.append(instance_config['newinstance'])
    #     m1.stop(True)
    #     m1.start(True)
    cn = m1.setupBackend("dc=example2,dc=com")
    rc = m1.setupSuffix("dc=example2,dc=com", cn)
    entry = m1.getEntry(DN_CONFIG, ldap.SCOPE_SUBTREE, "(cn=" + cn + ")")
    print "new backend entry is:"
    print entry
    print entry.getValues('objectclass')
    print entry.OBJECTCLASS
    results = m1.search_s("cn=monitor", ldap.SCOPE_SUBTREE)
    print results
    results = m1.getBackendsForSuffix("dc=example,dc=com")
    print results

    print "done"
Example #4
0
def setup():
    # uses an existing 389 instance
    # add a suffix
    # add an agreement
    # This setup is quite verbose but to test dsadmin method we should
    # do things manually. A better solution would be to use an LDIF.
    global conn
    conn = DSAdmin(**config.auth)
    conn.verbose = True
    conn.added_entries = []
    conn.added_backends = set(["o=mockbe1"])
    conn.added_replicas = []

    # add a backend for testing ruv and agreements
    addbackend_harn(conn, "testReplica")

    # add another backend for testing replica.add()
    addbackend_harn(conn, "testReplicaCreation")
def default_test():
    host = 'localhost'
    port = 10200
    binddn = "cn=directory manager"
    bindpw = "password"
    suffix = 'dc=example,dc=com'
    basedn = DN_CONFIG
    scope = ldap.SCOPE_BASE
    filt = "(objectclass=*)"
    instance_name = ['m1', 'm2']

    instance_config = {
        'cfgdshost': host,
        'cfgdsport': port,
        'cfgdsuser': '******',
        'cfgdspwd': 'admin',
        'newrootpw': 'password',
        'newhost': host,
        'newport': port,
        'newinstance': instance_name[0],
        'newsuffix': suffix,
        'setup_admin': True,
    }
    try:
        m1 = DSAdmin(host, port, binddn, bindpw)
    except:
        m1 = DSAdminTools.createInstance(instance_config, verbose=1)
        added_instances.append(instance_config['newinstance'])

#        filename = "%s/slapd-%s/ldif/Example.ldif" % (m1.sroot, m1.inst)
#        m1.importLDIF(filename, "dc=example,dc=com", None, True)
#        m1.exportLDIF('/tmp/ldif', "dc=example,dc=com", False, True)
    print m1.sroot, m1.inst, m1.errlog
    ent = m1.getEntry(basedn, scope, filt, None)
    if ent:
        print ent.passwordmaxage
    instance_config.update({
                           'newinstance': instance_name[1],
                           'newport': port + 10,

                           })
    m1 = DSAdminTools.createInstance(instance_config, verbose=1)
    added_instances.append(instance_config['newinstance'])
#     m1.stop(True)
#     m1.start(True)
    cn = m1.setupBackend("dc=example2,dc=com")
    rc = m1.setupSuffix("dc=example2,dc=com", cn)
    entry = m1.getEntry(DN_CONFIG, ldap.SCOPE_SUBTREE, "(cn=" + cn + ")")
    print "new backend entry is:"
    print entry
    print entry.getValues('objectclass')
    print entry.OBJECTCLASS
    results = m1.search_s("cn=monitor", ldap.SCOPE_SUBTREE)
    print results
    results = m1.getBackendsForSuffix("dc=example,dc=com")
    print results

    print "done"
Example #6
0
 def handle(self,dn,entry):
     """
     Append single record to dictionary of all records.
     """
     ent = Entry((dn, entry))
     normdn = DSAdmin.normalizeDN(dn)
     self.dndict[normdn] = ent
     cn = ent.cn
     if cn:
         self.cndict[cn] = ent
     self.dnlist.append(ent);
Example #7
0
 def handle(self, dn, entry):
     """
     Append single record to dictionary of all records.
     """
     ent = Entry((dn, entry))
     normdn = DSAdmin.normalizeDN(dn)
     self.dndict[normdn] = ent
     cn = ent.cn
     if cn:
         self.cndict[cn] = ent
     self.dnlist.append(ent)
Example #8
0
def setup():
    global conn
    conn = DSAdmin(**config.auth)
    conn.verbose = True
    conn.added_entries = []
    conn.added_backends = set(['o=mockbe2'])
    conn.added_replicas = []
    harn_nolog()
Example #9
0
 def handle(self,dn,entry):
     """
     assumes basedns[0] is the parent, basedns[1] already exists,
     and we want to create entries for basedns[2]
     """
     normdn = DSAdmin.normalizeDN(dn)
     for (basedn, ld) in self.iterlist:
         if normdn.endswith(basedn):
             ld.unparse(dn,entry)
             if basedn == self.basedns[1]:
                 dn = normdn.replace(basedn,self.basedns[2])
                 for (attr, vals) in entry.iteritems():
                     for ii in xrange(0, len(vals)):
                         vals[ii] = vals[ii].replace(basedn,self.basedns[2])
                 self.outldifs[2].unparse(dn,entry)
             break
Example #10
0
def setup():
    # uses an existing 389 instance
    # add a suffix
    # add an agreement
    # This setup is quite verbose but to test dsadmin method we should
    # do things manually. A better solution would be to use an LDIF.
    global conn
    conn = DSAdmin(**config.auth)
    conn.verbose = True
    conn.added_entries = []
    conn.added_backends = set(['o=mockbe1'])
    conn.added_replicas = []
    """  
Example #11
0
import os
import sys
import time
import ldap
from dsadmin import DSAdmin, Entry

host1, port1, dn1, pw1, host2, port2, dn2, pw2 = sys.argv[1:]

srv1 = DSAdmin(host1, int(port1), dn1, pw1)
srv2 = DSAdmin(host2, int(port2), dn2, pw2)

agmts1to2 = srv1.findAgreementDNs()
agmts2to1 = srv2.findAgreementDNs()

suffixes = {}
srv1.lastnumchanges = {}
srv2.lastnumchanges = {}
srv1.avgrate = {}
srv2.avgrate = {}
srv1.count = {}
srv2.count = {}
repls = {}
for dn in agmts1to2:
    ents = srv1.search_s(dn, ldap.SCOPE_BASE, 'objectclass=*',
                         ['nsDS5ReplicaRoot'])
    ndn = DSAdmin.normalizeDN(dn)
    nrr = DSAdmin.normalizeDN(ents[0].nsDS5ReplicaRoot)
    suffixes[nrr] = dn
    srv1.lastnumchanges[ndn] = 0
    rdns = ldap.explode_dn(dn, 0)
    ndn = DSAdmin.normalizeDN(','.join(rdns[1:]))
Example #12
0
rootdn2 = rootdn1
rootpw1 = "password"
rootpw2 = rootpw1

basedn = "dc=testdomain, dc=com"

m1replargs = {
	'suffix': basedn,
	'bename': "userRoot",
	'binddn': "cn=replrepl,cn=config",
	'bindcn': "replrepl",
	'bindpw': "replrepl"
}

#os.environ['USE_DBX'] = "1"
m1 = DSAdmin(host1, port1, rootdn1, rootpw1)
m1.replicaSetupAll(m1replargs)

m2replargs = m1replargs
#os.environ['USE_DBX'] = 1
m2 = DSAdmin(host2, port2, rootdn2, rootpw2)
m2.replicaSetupAll(m2replargs)

print "create agreements and init consumers"
agmtm1tom2 = m1.setupAgreement(m2, m1replargs)
m1.startReplication_async(agmtm1tom2)
print "waiting for init to finish"
m1.waitForReplInit(agmtm1tom2)
agmtm2tom1 = m2.setupAgreement(m1, m2replargs)

nents = 5
Example #13
0
m1replargs = {
	'suffix': basedn,
	'bename': "userRoot",
	'binddn': "cn=replrepl,cn=config",
	'bindcn': "replrepl",
	'bindpw': "replrepl",
        'pd': 5,
    'log'   : False
}
m2replargs = m1replargs

m1 = DSAdmin.createInstance({
	'newrootpw': 'password',
	'newhost': host1,
	'newport': port1,
	'newinst': 'm1',
	'newsuffix': basedn,
	'verbose': True,
    'no_admin': True
})

#os.environ['USE_GDB'] = "1"
m2 = DSAdmin.createInstance({
	'newrootpw': 'password',
	'newhost': host2,
	'newport': port2,
	'newinst': 'm2',
	'newsuffix': basedn,
	'verbose': False,
    'no_admin': True
})
Example #14
0
	'suffix': "dc=example,dc=com",
	'bename': "userRoot",
	'binddn': "cn=replrepl,cn=config",
	'bindcn': "replrepl",
	'bindpw': "replrepl",
    'log': True
}

#os.environ['USE_DBX'] = "1"
m1 = DSAdmin.createAndSetupReplica({
	'newrootpw': 'password',
	'newhost': host1,
	'newport': cfgport+10,
	'newinst': 'm1',
	'newsuffix': 'dc=example,dc=com',
    'cfgdshost': host1,
    'cfgdsport': cfgport,
    'cfgdsuser': '******',
    'cfgdspwd': 'admin',
	'verbose': True
}, m1replargs
)
#del os.environ['USE_DBX']

m2replargs = {
	'suffix': "dc=example,dc=com",
	'bename': "userRoot",
	'binddn': "cn=replrepl,cn=config",
	'bindcn': "replrepl",
	'bindpw': "replrepl",
    'log': True
Example #15
0
if ipawinsync:
    configfile = ['/share/dswinsyncipa/testipawinsyncplugin.ldif']
    schemafile = ['/share/freeipa/freeipa/ipa-server/ipa-install/share/60ipaconfig.ldif',
                  '/share/freeipa/freeipa/ipa-server/ipa-install/share/60kerberos.ldif',
                  '/share/freeipa/freeipa/ipa-server/ipa-install/share/60radius.ldif']
else:
    configfile = []
    schemafile = []

os.environ['USE_VALGRIND'] = "1"
ds = DSAdmin.createAndSetupReplica({
	'newrootpw': rootpw1,
	'newhost': host1,
	'newport': port1,
	'newinst': 'ds',
	'newsuffix': suffix,
	'verbose': False,
    'no_admin': True,
    'ConfigFile': configfile,
    'SchemaFile': schemafile
}, replargs
)
os.environ['USE_VALGRIND'] = ''
os.environ.pop('USE_VALGRIND')
try:
    foo = os.environ['USE_VALGRIND']
except KeyError:
    print "should no longer have USE_VALGRIND env. var"

if ipawinsync:
    print "Enable the memberof plugin . . ."
    dn = "cn=MemberOf Plugin,cn=plugins,cn=config"
Example #16
0
	'newport': port1,
	'newinst': 'm1',
	'newsuffix': basedn,
	'no_admin': True
}
m1replargs = {
	'suffix': basedn,
	'bename': "userRoot",
	'binddn': "cn=replrepl,cn=config",
	'bindcn': "replrepl",
	'bindpw': "replrepl",
        'starttls': True,
        'chain' : True
}

m1 = DSAdmin.createAndSetupReplica(m1createargs, m1replargs)
#del os.environ['USE_DBX']

#os.environ['USE_DBX'] = 1
# copy c1 args from m1
c1createargs = dict([(key,val) for key,val in m1createargs.iteritems()])
c1['newhost'] = host2
c1['newport'] = port2
c1['newinst'] = 'c1'
c1replargs = dict([(key,val) for key,val in m1replargs.iteritems()])
c1replargs['type'] = LEAF_TYPE
clreplargs['chainargs'] = {'nsUseStartTLS': 'TRUE'}

#os.environ['USE_DBX'] = "1"
c1 = DSAdmin.createAndSetupReplica(c1createargs, c1replargs)
#del os.environ['USE_DBX']
Example #17
0
    'ConfigFile': configfile,
    'no_admin': True
}

m1replargs = {
    'suffix': basedn,
    'bename': "userRoot",
    'binddn': "cn=replrepl,cn=config",
    'bindcn': "replrepl",
    'bindpw': "replrepl",
    'bindmethod': 'SASL/GSSAPI',
    'log': False
}

#os.environ['USE_GDB'] = "1"
m1 = DSAdmin.createAndSetupReplica(hostargs, m1replargs)
#del os.environ['USE_GDB']

hostargs['newhost'] = host2
hostargs['newport'] = port2
hostargs['newinst'] = 'm2'
m2replargs = m1replargs

m2 = DSAdmin.createAndSetupReplica(hostargs, m2replargs)

hostargs['newhost'] = host3
hostargs['newport'] = port3
hostargs['newinst'] = 'm3'
m3replargs = m2replargs

m3 = DSAdmin.createAndSetupReplica(hostargs, m3replargs)
Example #18
0
if len(args.H) != len(args.D) or len(args.H) != len(args.w):
    print "must provide the same number of host:port as binddn as bindpw"
    sys.exit(1)

sufary = args.b
suffixes = {}

conns = []
for ii in range(0, len(args.H)):
    ary = args.H[ii].split(':')
    host = ary[0]
    if len(ary) == 1:
        port = 389
    else:
        port = int(ary[1])
    conn = DSAdmin(host, port, args.D[ii], args.w[ii])
    conn.lastnumchanges = {}
    conn.avgrate = {}
    conn.count = {}
    conn.starttime = {}
    conn.endtime = {}
    conns.append(conn)
    sufary = args.b
    if not sufary:
        sufary = conn.getSuffixes()
    for suf in sufary:
        filt = '(nsds5replicaroot=' + suf + ')'
        agmts = conn.findAgreementDNs(filt)
        if not agmts:
#            raise Exception("error: server " + str(conn) + " has no agreements for suffix " + suf)
            print("error: server " + str(conn) + " has no agreements for suffix " + suf + " probably a consumer")
Example #19
0
host2 = "vmf9x8664"
port1 = 389
port2 = port1
rootpw = "secret12"

m1replargs = {
    'suffix': "dc=example,dc=com",
    'bename': "userRoot",
    'binddn': "cn=replrepl,cn=config",
    'bindcn': "replrepl",
    'bindpw': "replrepl"
    #    'log'   : False
}
m2replargs = m1replargs

m1 = DSAdmin(host1, port1, "cn=directory manager", rootpw)
m2 = DSAdmin(host2, port2, "cn=directory manager", rootpw)

m1.replicaSetupAll(m1replargs)
m2.replicaSetupAll(m2replargs)

print "create agreements and init consumers"
agmtm1tom2 = m1.setupAgreement(m2, m1replargs)
m1.startReplication_async(agmtm1tom2)
print "waiting for init to finish"
m1.waitForReplInit(agmtm1tom2)
agmtm2tom1 = m2.setupAgreement(m1, m2replargs)

sys.exit(0)

basedn = "dc=example,dc=com"
Example #20
0
    ntf3.write(line)
inf.close()
ntf3.write("""
dn: cn=myobj,%s
objectclass: person
objectclass: myobjclass
sn: me
myattr: somelongvalue

""" % basedn)
ntf3.close()
os.chmod(ntf3.name, 0644)

srv = DSAdmin.createInstance({
    'newrootpw': 'password',
    'newhost': host1,
    'newport': port1,
    'newinst': 'srv',
    'newsuffix': basedn,
    'verbose': False,
    'no_admin': True,
    'ConfigFile': [ntf.name],
    'SchemaFile': [ntf2.name],
    'InstallLdifFile': ntf3.name
})

os.unlink(ntf.name)
os.unlink(ntf2.name)
srv.importLDIF(ntf3.name, basedn, 'userRoot', True)
#os.unlink(ntf3.name)
Example #21
0
import os
import ldap
from dsadmin import DSAdmin, Entry

host1 = "localhost.localdomain"
host2 = host1
cfgport = 1100
port1 = cfgport + 30
port2 = port1 + 10

#os.environ['USE_DBX'] = "1"
m1 = DSAdmin.createInstance({
	'newrootpw': 'password',
	'newhost': host1,
	'newport': port1,
	'newinst': 'm1',
	'newsuffix': 'dc=example,dc=com',
	'verbose': True,
    'no_admin': True
})
#del os.environ['USE_DBX']

initfile = ''
if os.environ.has_key('SERVER_ROOT'):
    initfile = "%s/slapd-%s/ldif/Example.ldif" % (m1.sroot,m1.inst)
else:
    initfile = "%s/share/dirsrv/data/Example.ldif" % os.environ.get('PREFIX', '/usr')

m1.importLDIF(initfile, '', "userRoot", True)

#m1.setLogLevel(65535)
Example #22
0
import ldap
from dsadmin import DSAdmin, Entry, LEAF_TYPE
from ldap.controls import SimplePagedResultsControl

print "start"
host1 = "localhost.localdomain"
port1 = 1389
basedn = "dc=example,dc=com"
dom = 'example.com'
dnsdom = 'localdomain'

#os.environ['USE_VALGRIND'] = '1'
ds = DSAdmin.createInstance({
    'newrootpw': 'password',
    'newhost': host1,
    'newport': port1,
    'newinst': 'ds',
    'newsuffix': basedn,
    'no_admin': True
})

initfile = ''
if os.environ.has_key('SERVER_ROOT'):
    initfile = "%s/slapd-%s/ldif/Example.ldif" % (ds.sroot, ds.inst)
else:
    initfilesrc = "%s/share/dirsrv/data/Example.ldif" % os.environ.get(
        'PREFIX', '/usr')
    initfile = "%s/var/lib/dirsrv/slapd-%s/ldif/Example.ldif" % (
        os.environ.get('PREFIX', ''), 'ds')
    shutil.copy(initfilesrc, initfile)
print "importing database"
ds.importLDIF(initfile, '', "userRoot", False)
Example #23
0
changetype: modify
replace: nsslapd-threadnumber
nsslapd-threadnumber: 2

"""
)
cfgfd.close()
os.chmod(cfgfd.name, 0644)

createargs["ConfigFile"] = [cfgfd.name]
createargs["InstallLdifFile"] = "none"

# os.environ['USE_DBX'] = "1"
# os.environ['USE_CALLGRIND'] = "1"
print "create and setup m1"
m1 = DSAdmin.createInstance(createargs)
# del os.environ['USE_CALLGRIND']
# del os.environ['USE_DBX']

m2replargs = m1replargs
createargs["newhost"] = host2
createargs["newport"] = port2
createargs["newinst"] = "m2"
# os.environ['USE_GDB'] = "1"
print "create and setup m2"
m2 = DSAdmin.createInstance(createargs)
# del os.environ['USE_GDB']

os.unlink(cfgfd.name)

print "add entries to each suffix"
Example #24
0
m1replargs = {
	'suffix': suffix,
	'bename': "userRoot",
	'binddn': "cn=replrepl,cn=config",
	'bindcn': "replrepl",
	'bindpw': "replrepl",
    'log'   : True
}

#os.environ['USE_DBX'] = "1"
m1 = DSAdmin.createAndSetupReplica({
	'newrootpw': 'password',
	'newhost': host1,
	'newport': port1,
	'newinst': 'm1',
	'newsuffix': suffix,
	'verbose': True,
    'no_admin': True
}, m1replargs
)
#del os.environ['USE_DBX']

m2replargs = m1replargs
#os.environ['USE_DBX'] = 1
m2 = DSAdmin.createAndSetupReplica({
	'newrootpw': 'password',
	'newhost': host2,
	'newport': port2,
	'newinst': 'm2',
	'newsuffix': suffix,
	'verbose': True,
Example #25
0
    'newinst': 'm1',
    'newsuffix': basedn,
    'no_admin': True
}

m1replargs = {
	'suffix': basedn,
	'bename': "userRoot",
	'binddn': "cn=replrepl,cn=config",
	'bindcn': "replrepl",
	'bindpw': "replrepl"
}

#os.environ['USE_DBX'] = "1"
#os.environ['USE_CALLGRIND'] = "1"
m1 = DSAdmin.createAndSetupReplica(createargs, m1replargs)
#del os.environ['USE_CALLGRIND']
#del os.environ['USE_DBX']

if 'USE_DRD' in os.environ:
    del os.environ['USE_DRD']
if 'USE_CALLGRIND' in os.environ:
    del os.environ['USE_CALLGRIND']

m2replargs = m1replargs
createargs['newhost'] = host2
createargs['newport'] = port2
createargs['newinst'] = 'm2'
#os.environ['USE_GDB'] = "1"
m2 = DSAdmin.createAndSetupReplica(createargs, m2replargs)
#del os.environ['USE_GDB']
Example #26
0
 def __getattr__(self, name):
     if name in Replica.proxied_methods:
         return DSAdmin.__getattr__(self.conn, name)
Example #27
0
basedn = 'dc=example,dc=com'
replargs = {}
srvs = []
m1replargs = {
    'suffix': basedn,
    'bename': "userRoot",
    'binddn': "cn=replrepl,cn=config",
    'bindcn': "replrepl",
    'bindpw': "replrepl"
}
os.environ['USE_GDB'] = "1"
m1 = DSAdmin.createAndSetupReplica(
    {
        'newrootpw': 'password',
        'newhost': host1,
        'newport': port1,
        'newinst': 'm1',
        'newsuffix': basedn,
        'no_admin': True
    }, m1replargs)
del os.environ['USE_GDB']
replargs[m1] = m1replargs
srvs.append(m1)

m2replargs = m1replargs
m2 = DSAdmin.createAndSetupReplica(
    {
        'newrootpw': 'password',
        'newhost': host2,
        'newport': port2,
        'newinst': 'm2',
Example #28
0
import os
import sys
import time
import ldap
from dsadmin import DSAdmin, Entry, LEAF_TYPE

host1 = "vmf8i386.testdomain.com"
host2 = "vmf9x8664.testdomain.com"
port1 = 389
port2 = 389
rootdn1 = "cn=directory manager"
rootpw1 = 'secret12'
rootdn2 = "cn=directory manager"
rootpw2 = 'secret12'

mux = DSAdmin(host1, port1, rootdn1, rootpw1)
farm = DSAdmin(host2, port2, rootdn2, rootpw2)

suffix = 'dc=chaintest'
# add the suffix
farm.addSuffix(suffix)
# add the suffix entry
dn = suffix
ent = Entry(dn)
ent.setValues('objectclass', 'domain')
farm.add_s(ent)

# setup chaining
mux.setupChaining(farm, suffix, False)

# add ctuser on farm
Example #29
0
import os
import sys
import time
import ldap
import ldif
from dsadmin import DSAdmin, Entry

host1 = "localhost.localdomain"
port1 = 1200
basedn = "dc=example,dc=com"

srv = DSAdmin.createInstance({
    'newrootpw': 'password',
    'newhost': host1,
    'newport': port1,
    'newinst': 'srv',
    'newsuffix': basedn,
    'verbose': False,
    'no_admin': True
})

basedns = [basedn]
benames = ['userRoot']
base1 = "ou=people," + basedn
basedns.append(base1)
srv.addSuffix(base1)
ents = srv.getBackendsForSuffix(base1, ['cn'])
benames.append(ents[0].cn)
base2 = "ou=people1," + basedn
basedns.append(base2)
srv.addSuffix(base2)
Example #30
0
secport2 = port2+1
basedn = "dc=example,dc=com"
binddn = "cn=directory manager"
bindpw = "password"

#basedn = "dc=testdomain,dc=com"
#host1 = 'el4i386'
#port1 = 389
#m1 = DSAdmin(host1, port1, binddn, bindpw)

#os.environ['USE_VALGRIND'] = "1"
m1 = DSAdmin.createInstance({
	'newrootpw': 'password',
	'newhost': host1,
	'newport': port1,
	'newinst': 'm1',
	'newsuffix': basedn,
	'verbose': False,
    'no_admin': True
})
#del os.environ['USE_VALGRIND']

# initfile = ''
# if os.environ.has_key('SERVER_ROOT'):
#     initfile = "%s/slapd-%s/ldif/Example.ldif" % (m1.sroot,m1.inst)
# else:
#     initfile = "%s/share/dirsrv/data/Example.ldif" % os.environ.get('PREFIX', '/usr')
# m1.importLDIF(initfile, '', "userRoot", True)

print "show active connections . . ."
ents = m1.search_s("cn=monitor", ldap.SCOPE_BASE, '(objectclass=*)', ['currentconnections', 'connection'])
Example #31
0
port2 = port1 + 1000

m1replargs = {
    'suffix': "dc=example,dc=com",
    'bename': "userRoot",
    'binddn': "cn=replrepl,cn=config",
    'bindcn': "replrepl",
    'bindpw': "replrepl"
}

#os.environ['USE_DBX'] = "1"
m1 = DSAdmin.createAndSetupReplica(
    {
        'newrootpw': 'password',
        'newhost': host1,
        'newport': port1,
        'newinst': 'm1',
        'newsuffix': 'dc=example,dc=com',
        'no_admin': True
    }, m1replargs)
#del os.environ['USE_DBX']

m2replargs = {
    'suffix': "dc=example,dc=com",
    'bename': "userRoot",
    'binddn': "cn=replrepl,cn=config",
    'bindcn': "replrepl",
    'bindpw': "replrepl"
}
#os.environ['USE_DBX'] = 1
m2 = DSAdmin.createAndSetupReplica(
Example #32
0
port1 = cfgport + 10
port2 = cfgport + 20
root1 = "cn=directory manager"
root2 = root1
rootpw1 = 'password'
rootpw2 = rootpw1
suffix = "dc=example,dc=com"
scope = ldap.SCOPE_SUBTREE
filt = '(objectclass=*)'

os.environ['USE_VALGRIND'] = "1"
m1 = DSAdmin.createInstance({
    'newrootpw': rootpw1,
    'newhost': host1,
    'newport': port1,
    'newinst': 'm1',
    'newsuffix': suffix,
    'verbose': False,
    'no_admin': True
})

dn = "ou=virtualviews," + suffix
ent = Entry(dn)
ent.setValues('objectclass', 'organizationalUnit')
print "Create view ou", dn
m1.add_s(ent)

mod = [(ldap.MOD_REPLACE, 'objectclass',
        ['top', 'organizationalUnit', 'nsView'])]
print "add nsview to", dn
m1.modify_s(dn, mod)
Example #33
0
from dsadmin import DSAdmin, Entry, LEAF_TYPE

host1 = "localhost.localdomain"
host2 = host1
port1 = 1130
port2 = port1+10
rootdn1 = "cn=directory manager"
rootpw1 = 'password'
rootdn2 = rootdn1
rootpw2 = rootpw1
suffix = "dc=example,dc=com"

mux = DSAdmin.createInstance({
	'newrootpw': rootpw1,
	'newhost': host1,
	'newport': port1,
	'newinst': 'mux',
	'newsuffix': 'dc=notused',
    'no_admin': True
})

os.environ['USE_GDB'] = "1"
farm = DSAdmin.createInstance({
	'newrootpw': rootpw2,
	'newhost': host2,
	'newport': port2,
	'newinst': 'farm',
	'newsuffix': 'dc=notused',
    'no_admin': True
})

# add the suffix
Example #34
0
from dsadmin import DSAdmin, Entry
from ldap.ldapobject import SimpleLDAPObject
import pprint

host1 = "localhost.localdomain"
port1 = 1110
basedn = 'dc=example,dc=com'

ldapifilepath = os.environ.get('PREFIX', "") + "/var/run/slapd-srv.socket"

os.environ['USE_GDB'] = "1"
srv = DSAdmin.createInstance({
	'newrootpw': 'password',
	'newhost': host1,
	'newport': port1,
	'newinst': 'srv',
	'newsuffix': basedn,
    'no_admin': True,
    'ldapifilepath': ldapifilepath
})
del os.environ['USE_GDB']

ldapiurl = ldapurl.LDAPUrl(None, "ldapi", ldapifilepath)

conn = SimpleLDAPObject(ldapiurl.initializeUrl())
print "connecting to", ldapiurl.initializeUrl()

conn.simple_bind_s("cn=directory manager", "password")
ents = conn.search_s("", ldap.SCOPE_BASE)
pprint.pprint(ents)
Example #35
0
#os.environ['USE_DBX'] = "1"
m1replargs = {
	'suffix': "dc=example,dc=com",
	'bename': "userRoot",
	'binddn': "cn=replrepl,cn=config",
	'bindcn': "replrepl",
	'bindpw': "replrepl"
}

m1 = DSAdmin.createAndSetupReplica({
	'cfgdshost': host1,
	'cfgdsport': cfgport,
	'cfgdsuser': '******',
	'cfgdspwd': 'admin',
	'newrootpw': 'password',
	'newhost': host1,
	'newport': port1,
	'newinst': 'm1',
	'newsuffix': 'dc=example,dc=com',
	'verbose': True
}, m1replargs)
#del os.environ['USE_DBX']

m2replargs = {
	'suffix': "dc=example,dc=com",
	'bename': "userRoot",
	'binddn': "cn=replrepl,cn=config",
	'bindcn': "replrepl",
	'bindpw': "replrepl"
}
Example #36
0
cfgport = 1100

mreplargs = {
    'suffix': "dc=example,dc=com",
    'bename': "userRoot",
    'binddn': "cn=replrepl,cn=config",
    'bindcn': "replrepl",
    'bindpw': "replrepl"
}

#os.environ['USE_DBX'] = "1"
m = DSAdmin.createAndSetupReplica(
    {
        'newrootpw': 'password',
        'newhost': host1,
        'newport': cfgport + 10,
        'newinst': 'm',
        'newsuffix': 'dc=example,dc=com',
        'verbose': True,
        'no_admin': True
    }, mreplargs)
#del os.environ['USE_DBX']

hreplargs = {
    'suffix': "dc=example,dc=com",
    'bename': "userRoot",
    'binddn': "cn=replrepl,cn=config",
    'bindcn': "replrepl",
    'bindpw': "replrepl",
    'type': dsadmin.HUB_TYPE
}
#os.environ['USE_DBX'] = 1
Example #37
0
import os
import ldap
from dsadmin import DSAdmin, Entry

host1 = "localhost.localdomain"
host2 = host1
cfgport = 1100
port1 = cfgport + 30
port2 = port1 + 10

#os.environ['USE_DBX'] = "1"
m1 = DSAdmin.createInstance({
	'newrootpw': 'password',
	'newhost': host1,
	'newport': port1,
	'newinst': 'm1',
	'newsuffix': 'dc=example,dc=com',
	'verbose': True,
    'no_admin': True
})
#del os.environ['USE_DBX']

initfile = ''
if os.environ.has_key('SERVER_ROOT'):
    initfile = "%s/slapd-%s/ldif/Example.ldif" % (m1.sroot,m1.inst)
else:
    initfile = "%s/share/dirsrv/data/Example.ldif" % os.environ.get('PREFIX', '/usr')

m1.importLDIF(initfile, '', "userRoot", True)
Example #38
0
m1replargs = {
	'suffix': "dc=example,dc=com",
	'bename': "userRoot",
	'binddn': "cn=replrepl,cn=config",
	'bindcn': "replrepl",
	'bindpw': "replrepl",
    'log'   : True
}

#os.environ['USE_DBX'] = "1"
m1 = DSAdmin.createAndSetupReplica({
	'newrootpw': 'password',
	'newhost': host1,
	'newport': cfgport+10,
	'newinst': 'm1',
	'newsuffix': 'dc=example,dc=com',
	'verbose': True,
    'no_admin': True
}, m1replargs
)
#del os.environ['USE_DBX']

m2replargs = {
	'suffix': "dc=example,dc=com",
	'bename': "userRoot",
	'binddn': "cn=replrepl,cn=config",
	'bindcn': "replrepl",
	'bindpw': "replrepl"
}
#os.environ['USE_DBX'] = 1
m2 = DSAdmin.createAndSetupReplica({
Example #39
0
m1replargs = {
    'suffix': basedn,
    'bename': "userRoot",
    'binddn': "cn=replrepl,cn=config",
    'bindcn': "replrepl",
    'bindpw': "replrepl",
    'log': True
}

#os.environ['USE_DBX'] = "1"
m1 = DSAdmin.createAndSetupReplica(
    {
        'newrootpw': 'password',
        'newhost': host1,
        'newport': port1,
        'newinst': 'm1',
        'newsuffix': basedn,
        'verbose': True,
        'no_admin': True
    }, m1replargs)
#del os.environ['USE_DBX']

m2replargs = m1replargs

#os.environ['USE_DBX'] = 1
m2 = DSAdmin.createAndSetupReplica(
    {
        'newrootpw': 'password',
        'newhost': host2,
        'newport': port2,
        'newinst': 'm2',
Example #40
0
    'newport': port1,
    'newinst': 'm1',
    'newsuffix': basedn,
    'no_admin': True
}
m1replargs = {
    'suffix': basedn,
    'bename': "userRoot",
    'binddn': "cn=replrepl,cn=config",
    'bindcn': "replrepl",
    'bindpw': "replrepl",
    'starttls': True,
    'chain': True
}

m1 = DSAdmin.createAndSetupReplica(m1createargs, m1replargs)
#del os.environ['USE_DBX']

#os.environ['USE_DBX'] = 1
# copy c1 args from m1
c1createargs = dict([(key, val) for key, val in m1createargs.iteritems()])
c1['newhost'] = host2
c1['newport'] = port2
c1['newinst'] = 'c1'
c1replargs = dict([(key, val) for key, val in m1replargs.iteritems()])
c1replargs['type'] = LEAF_TYPE
clreplargs['chainargs'] = {'nsUseStartTLS': 'TRUE'}

#os.environ['USE_DBX'] = "1"
c1 = DSAdmin.createAndSetupReplica(c1createargs, c1replargs)
#del os.environ['USE_DBX']
Example #41
0
nsslapd-pluginType: betxnpostoperation

dn: %s
changetype: modify
replace: nsslapd-db-logbuf-size
nsslapd-db-logbuf-size: 10000000
""" % (dn1, dn2))
cfgfd.close()
os.chmod(cfgfd.name, 0644)

#os.environ['USE_VALGRIND'] = '1'
ds = DSAdmin.createInstance({
	'newrootpw': 'password',
	'newhost': host1,
	'newport': port1,
	'newinst': 'ds',
	'newsuffix': basedn,
	'no_admin': True,
        'ConfigFile': [cfgfd.name]
})
os.unlink(cfgfd.name)

initfile = ''
if os.environ.has_key('SERVER_ROOT'):
    initfile = "%s/slapd-%s/ldif/Example.ldif" % (ds.sroot,ds.inst)
else:
    initfilesrc = "%s/share/dirsrv/data/Example.ldif" % os.environ.get('PREFIX', '/usr')
    initfile = "%s/var/lib/dirsrv/slapd-%s/ldif/Example.ldif" % (os.environ.get('PREFIX', ''), 'ds')
    shutil.copy(initfilesrc, initfile)
print "importing database"
ds.importLDIF(initfile, '', "userRoot", False)
Example #42
0
basedn = 'dc=example,dc=com'
replargs = {}
srvs = []
m1replargs = {
	'suffix': basedn,
	'bename': "userRoot",
	'binddn': "cn=replrepl,cn=config",
	'bindcn': "replrepl",
	'bindpw': "replrepl"
}
os.environ['USE_GDB'] = "1"
m1 = DSAdmin.createAndSetupReplica({
	'newrootpw': 'password',
	'newhost': host1,
	'newport': port1,
	'newinst': 'm1',
	'newsuffix': basedn,
    'no_admin': True
}, m1replargs
)
del os.environ['USE_GDB']
replargs[m1] = m1replargs
srvs.append(m1)

m2replargs = m1replargs
m2 = DSAdmin.createAndSetupReplica({
	'newrootpw': 'password',
	'newhost': host2,
	'newport': port2,
	'newinst': 'm2',
	'newsuffix': basedn,
Example #43
0
from dsadmin import DSAdmin, Entry
from ldap.ldapobject import SimpleLDAPObject
import pprint

host1 = "localhost.localdomain"
port1 = 1110
basedn = 'dc=example,dc=com'

ldapifilepath = os.environ.get('PREFIX', "") + "/var/run/slapd-srv.socket"

os.environ['USE_GDB'] = "1"
srv = DSAdmin.createInstance({
    'newrootpw': 'password',
    'newhost': host1,
    'newport': port1,
    'newinst': 'srv',
    'newsuffix': basedn,
    'no_admin': True,
    'ldapifilepath': ldapifilepath
})
del os.environ['USE_GDB']

ldapiurl = ldapurl.LDAPUrl(None, "ldapi", ldapifilepath)

conn = SimpleLDAPObject(ldapiurl.initializeUrl())
print "connecting to", ldapiurl.initializeUrl()

conn.simple_bind_s("cn=directory manager", "password")
ents = conn.search_s("", ldap.SCOPE_BASE)
pprint.pprint(ents)
Example #44
0
        '/share/freeipa/freeipa/install/share/60ipaconfig.ldif',
        '/share/freeipa/freeipa/install/share/60kerberos.ldif'
    ]
#                  '/share/freeipa/freeipa/install/share/60radius.ldif']
else:
    configfile = []
    schemafile = []
    cfgfd = None

os.environ['USE_GDB'] = "1"
ds = DSAdmin.createInstance({
    'newrootpw': rootpw1,
    'newhost': host1,
    'newport': port1,
    'newinst': 'ds',
    'newsuffix': suffix,
    'verbose': False,
    'no_admin': True,
    'ConfigFile': configfile,
    'SchemaFile': schemafile
})
if cfgfd:
    os.unlink(cfgfd.name)

ds.setupSSL(secport1)

ds.replicaSetupAll(replargs)

if ipawinsync:
    print "Enable the memberof plugin . . ."
    dn = "cn=MemberOf Plugin,cn=plugins,cn=config"
Example #45
0
import os
import time
import ldap
from dsadmin import DSAdmin, Entry

host = "localhost.localdomain"
port = 10200

#os.environ['USE_DBX'] = "1"
#del os.environ['USE_DBX']

binddn = "cn=directory manager"
bindpw = "secret12"
conn = DSAdmin(host,port,binddn,bindpw)

suffix = "dc=example2,dc=com"
conn.addSuffix(suffix)

initfile = "/var/tmp/reftest.ldif"
conn.importLDIF(initfile, suffix, None, True)
Example #46
0
    ntf3.write(line)
inf.close()
ntf3.write("""
dn: cn=myobj,%s
objectclass: person
objectclass: myobjclass
sn: me
myattr: somelongvalue

""" % basedn)
ntf3.close()
os.chmod(ntf3.name, 0644)

srv = DSAdmin.createInstance({
    'newrootpw': 'password',
    'newhost': host1,
    'newport': port1,
    'newinst': 'srv',
    'newsuffix': basedn,
    'verbose': False,
    'no_admin': True,
    'ConfigFile':[ntf.name],
    'SchemaFile':[ntf2.name],
    'InstallLdifFile':ntf3.name
})

os.unlink(ntf.name)
os.unlink(ntf2.name)
srv.importLDIF(ntf3.name,basedn,'userRoot',True)
#os.unlink(ntf3.name)
Example #47
0
m1replargs = {
    'suffix': basedn,
    'bename': "userRoot",
    'binddn': "cn=replrepl,cn=config",
    'bindcn': "replrepl",
    'bindpw': "replrepl",
    'log': False
}
m2replargs = m1replargs

os.environ['USE_VALGRIND'] = "1"
m1 = DSAdmin.createInstance({
    'newrootpw': 'password',
    'newhost': host1,
    'newport': port1,
    'newinst': 'm1',
    'newsuffix': basedn,
    'verbose': False,
    'no_admin': True
})
del os.environ['USE_VALGRIND']

m2 = DSAdmin.createInstance({
    'newrootpw': 'password',
    'newhost': host2,
    'newport': port2,
    'newinst': 'm2',
    'newsuffix': basedn,
    'verbose': False,
    'no_admin': True
})
Example #48
0
dn: cn=config
changetype: modify
replace: nsslapd-threadnumber
nsslapd-threadnumber: 2

""")
cfgfd.close()
os.chmod(cfgfd.name, 0644)

createargs['ConfigFile'] = [cfgfd.name]
createargs['InstallLdifFile'] = 'none'

#os.environ['USE_DBX'] = "1"
#os.environ['USE_CALLGRIND'] = "1"
print "create and setup m1"
m1 = DSAdmin.createInstance(createargs)
#del os.environ['USE_CALLGRIND']
#del os.environ['USE_DBX']

m2replargs = m1replargs
createargs['newhost'] = host2
createargs['newport'] = port2
createargs['newinst'] = 'm2'
#os.environ['USE_GDB'] = "1"
print "create and setup m2"
m2 = DSAdmin.createInstance(createargs)
#del os.environ['USE_GDB']

os.unlink(cfgfd.name)

print "add entries to each suffix"
Example #49
0
import time
import ldap
import ldif
import tempfile
from dsadmin import DSAdmin, Entry

host1 = "localhost.localdomain"
port1 = 1110
basedn = "dc=example,dc=com"

os.environ["USE_GDB"] = "1"
srv = DSAdmin.createInstance(
    {
        "newrootpw": "password",
        "newhost": host1,
        "newport": port1,
        "newinst": "srv",
        "newsuffix": basedn,
        "no_admin": True,
    }
)
del os.environ["USE_GDB"]

initfile = ""
if os.environ.has_key("SERVER_ROOT"):
    initfile = "%s/slapd-%s/ldif/Example.ldif" % (srv.sroot, srv.inst)
else:
    initfile = "%s/share/dirsrv/data/Example.ldif" % os.environ.get("PREFIX", "/usr")

print "import the ldif file"
srv.importLDIF(initfile, "", "userRoot", True)
Example #50
0
m1replargs = {
	'suffix': basedn,
	'bename': "userRoot",
	'binddn': "cn=replrepl,cn=config",
	'bindcn': "replrepl",
	'bindpw': "replrepl",
    'log'   : True
}

#os.environ['USE_DBX'] = "1"
m1 = DSAdmin.createAndSetupReplica({
	'newrootpw': 'password',
	'newhost': host1,
	'newport': port1,
	'newinst': 'm1',
	'newsuffix': basedn,
	'verbose': True,
    'no_admin': True
}, m1replargs
)
#del os.environ['USE_DBX']

m2replargs = m1replargs

#os.environ['USE_DBX'] = 1
m2 = DSAdmin.createAndSetupReplica({
	'newrootpw': 'password',
	'newhost': host2,
	'newport': port2,
	'newinst': 'm2',
	'newsuffix': basedn,
Example #51
0
    configfile = [cfgfd.name]
    schemafile = ['/share/freeipa/freeipa/install/share/60ipaconfig.ldif',
                  '/share/freeipa/freeipa/install/share/60kerberos.ldif']
#                  '/share/freeipa/freeipa/install/share/60radius.ldif']
else:
    configfile = []
    schemafile = []
    cfgfd = None

os.environ['USE_GDB'] = "1"
ds = DSAdmin.createInstance({
	'newrootpw': rootpw1,
	'newhost': host1,
	'newport': port1,
	'newinst': 'ds',
	'newsuffix': suffix,
	'verbose': False,
        'no_admin': True,
        'ConfigFile': configfile,
        'SchemaFile': schemafile
})
if cfgfd:
    os.unlink(cfgfd.name)

ds.setupSSL(secport1)

ds.replicaSetupAll(replargs)

if ipawinsync:
    print "Enable the memberof plugin . . ."
    dn = "cn=MemberOf Plugin,cn=plugins,cn=config"
Example #52
0
    'newinst': 'm1',
    'newsuffix': 'dc=example,dc=com',
    'no_admin': True
}

m1replargs = {
    'suffix': "dc=example,dc=com",
    'bename': "userRoot",
    'binddn': "cn=replrepl,cn=config",
    'bindcn': "replrepl",
    'bindpw': "replrepl"
}

#os.environ['USE_DBX'] = "1"
#os.environ['USE_CALLGRIND'] = "1"
m1 = DSAdmin.createAndSetupReplica(createargs, m1replargs)
#del os.environ['USE_CALLGRIND']
#del os.environ['USE_DBX']

if 'USE_DRD' in os.environ:
    del os.environ['USE_DRD']
if 'USE_CALLGRIND' in os.environ:
    del os.environ['USE_CALLGRIND']

m2replargs = m1replargs
createargs['newhost'] = host2
createargs['newport'] = port2
createargs['newinst'] = 'm2'
os.environ['USE_GDB'] = "1"
m2 = DSAdmin.createAndSetupReplica(createargs, m2replargs)
del os.environ['USE_GDB']
Example #53
0
from dirsyncctrl import DirSyncCtrl

host1 = "vmhost.testdomain.com"
port1 = 1200
secport1 = port1 + 1
rootdn = "cn=directory manager"
rootpw = "password"

basedn = 'dc=example,dc=com'
newinst = 'ds'
os.environ['USE_VALGRIND'] = "1"

srv = DSAdmin.createInstance({
    'newrootpw': rootpw,
    'newhost': host1,
    'newport': port1,
    'newinst': newinst,
    'newsuffix': basedn,
    'no_admin': True
})

print "turn on syntax checking and trivial words checking"
attr = "passwordCheckSyntax"
mod = [(ldap.MOD_REPLACE, attr, "on")]
srv.modify_s("cn=config", mod)

print "add a user with a password"
dn = "uid=scarter,dc=example,dc=com"
bindpw = "SPrain12"
ent = Entry(dn)
ent.setValues('objectclass', 'inetOrgPerson')
ent.setValues('cn', 'Sam Carter')
Example #54
0
host2 = host1
port1 = 1200
port2 = port1 + 10
secport1 = port1 + 1
secport2 = port2 + 1

basedn = 'dc=example,dc=com'
#os.environ['USE_VALGRIND'] = "1"
m1 = DSAdmin.createInstance({
    'newrootpw':
    'password',
    'newhost':
    host1,
    'newport':
    port1,
    'newinst':
    'm1',
    'newsuffix':
    basedn,
    'no_admin':
    True,
    'InstallLdifFile':
    os.environ.get('PREFIX', '/usr') + "/share/dirsrv/data/Example.ldif"
})
#del os.environ['USE_VALGRIND']

#os.environ['USE_VALGRIND'] = "1"
m2 = DSAdmin.createInstance({
    'newrootpw': 'password',
    'newhost': host2,
    'newport': port2,
    'newinst': 'm2',