def get_storage_location(self, storage): retval = LDAP couchbase_mappings = [ s.strip() for s in self.conf_prop['storage.couchbase.mapping'].split(',') ] if self.conf_prop["persistence.type"] in storage_types: retval = storage_types[self.conf_prop["persistence.type"]] elif storage == 'default': retval = storage_types[self.conf_prop['storage.default']] else: if storage in couchbase_mappings: retval = COUCHBASE if (retval == COUCHBASE) and (not self.cbm): cbp = get_properties(setupObject.gluuCouchebaseProperties) cbm_hostname = cbp['servers'].split(',')[0] cbm_username = cbp['auth.userName'] cbm_pass = unobscure(cbp['auth.userPassword']) self.cbm = CBM(cbm_hostname, cbm_username, cbm_pass) elif (retval == LDAP) and (not self.ldap_conn): lp = get_properties(setupObject.ox_ldap_properties) ldap_pass = unobscure(lp['bindPassword']) ldap_hostname, ldap_port = lp['servers'].split(',')[0].split(':') self.ldap_conn = ldap.initialize('ldaps://{0}:{1}'.format( ldap_hostname, ldap_port)) self.ldap_conn.simple_bind_s('cn=directory manager', ldap_pass) return retval
ldap_conn.simple_bind_s(ldap_binddn, ldap_password) basedn = 'inum=OO11-BAFE,ou=scripts,o=gluu' result = ldap_conn.search_s(basedn, ldap.SCOPE_BASE, attrlist=['oxEnabled']) if result and result[0][1]['oxEnabled'][0].lower() != 'true': ldap_conn.modify_s(basedn, [(ldap.MOD_REPLACE, 'oxEnabled', 'true')]) else: # Obtain couchbase credidentals for l in open(setupObject.gluuCouchebaseProperties): ls = l.strip() n = ls.find(':') if ls.startswith('servers'): server = ls[n + 1:].strip().split(',')[0].strip() elif ls.startswith('auth.userName'): userName = ls[n + 1:].strip() elif ls.startswith('auth.userPassword'): userPasswordEnc = ls[n + 1:].strip() userPassword = os.popen('/opt/gluu/bin/encode.py -D {}'.format( userPasswordEnc)).read().strip() cbm = CBM(server, userName, userPassword) result = cbm.exec_query( 'UPDATE `gluu` USE KEYS "scripts_OO11-BAFE" SET `oxEnabled`=true') print("Restarting identity, this will take a while") setupObject.run_service_command('identity', 'restart')