Sustitución por anomalía de seguridad entre varios servidores LDAP
La seguridad de WebSphere Application Server puede configurarse para intentar sustituciones por anomalía entre varios hosts LDAP (Lightweight Directory Access Protocol).
Si el servidor LDAP activo actual no está disponible, la seguridad de WebSphere Application Server intenta una sustitución por anomalía en el primer host LDAP disponible en la lista de hosts especificada. Los distintos servidores LDAP pueden se replicas del mismo servidor LDAP maestro o pueden ser cualquier host LDAP con el mismo esquema, que contiene los datos que se importan desde el mismo archivo LDIF (LDAP Data Interchange Format).
Cuando ocurre una sustitución por anomalía, la seguridad de WebSphere Application Server siempre utiliza el primer servidor LDAP disponible en la lista de hosts especificada. Por ejemplo, si existen cuatro servidores LDAP en el orden L1, L2, L3 y L4, L1 recibe el tratamiento de servidor LDAP principal. La preferencia de conexión va de L1 a L4. Si, por ejemplo, la seguridad de WebSphere Application Server está actualmente conectada a L4 y la sustitución por anomalía o la reconexión son necesarias, la seguridad de WebSphere Application Server primero intenta conectarse a L1, L2 y L3 en ese orden hasta que la conexión sea satisfactoria.
El nombre de host LDAP actual se registra en el mensaje SECJ0419I del archivo de registro de WebSphere Application Server, SystemOut.log. Si desea volver a conectarse al host LDAP principal, ejecute el método de MBean de WebSphere Application Server, resetLDAPBindInfo, con null,null como entrada.
Para configurar la sustitución por anomalía de LDAP entre varios hosts LDAP, debe utilizar wsadmin o ConfigService para incluir el host LDAP de copia de seguridad, que no tiene una limitación de número. El host LDAP que se muestra en la consola administrativa es el host LDAP principal y es el primer elemento enumerado en la lista de hosts LDAP de security.xml.
La nombre de reino de seguridad de WebSphere Application Server toma como valor predeterminado el nombre de host LDAP principal que se muestra en la consola administrativa. Incluye dos puntos finales y número de puerto (si existe). No obstante, la propiedad personalizada com.ibm.websphere.security.ldap.logicRealm puede añadirse para alterar temporalmente el nombre de reino de seguridad. Utilice el nombre logicRealm para configurar cada célula de modo tenga su propio host LDAP para la interoperatividad y la compatibilidad con versiones anteriores y para proporcionar la flexibilidad necesaria para añadir o eliminar el LDAP dinámicamente. Si está migrando de una instalación anterior, el nuevo nombre logicRealm no entra en vigor hasta que la seguridad administrativa está habilitada de nuevo. Para que sea compatible con una versión anterior que no soporta el reino lógico, el nombre logicRealm debe ser el mismo nombre que se utiliza en la instalación anterior (el nombre de host LDAP, incluidos dos puntos y un número de puerto).
Cuando la migración tras error de LDAP se configura asociando un nombre de host individual a varias direcciones IP mediante el uso de un equilibrador de carga (que hace que la conversión sea transparente para WebSphere Application Server) la especificación de una contraseña no válida puede provocar varios reintentos de enlace LDAP. WebSphere Application Server reintenta y dirige las solicitudes del equilibrador de carga a varias réplicas. Con los valores predeterminados, el número de reintentos de enlaces LDAP es igual a uno más el número de direcciones IP asociadas. Esto significa que un solo intento de inicio de sesión no válido puede hacer que se bloquee la cuenta LDAP. Si la propiedad personalizada com.ibm.websphere.security.registry.ldap.singleLDAP se establece en false, no se reintentan las llamadas de enlace LDAP.
Cuando se ha configurado la migración tras error de LDAP registrando nombres de host de servidor LDAP de fondo utilizando el mandato wsadmin, establezca la propiedad com.ibm.websphere.security.ldap.retryBind en false.
#---------------------------------------------------------------
# Main
# This is a bi-modal script: it can be included in the wsadmin
# command invocation like this:
# wsadmin -f LDAPAdd.jacl ldaphost 800
#
# or the script can be sourced from the wsadmin command line:
# wsadmin> source LDAPAdd.jacl
# wsadmin> LDAPAdd ldaphost 800
#
# The script expects some parameters:
# arg1 - LDAP Server host name
# arg2 - LDAP Server port number
#---------------------------------------------------------------
if { !($argc == 2)} {
puts ""
puts "LDAPAdd: This script requires 2 parameters: LDAP server host name and LDAP server port number"
puts "For example: LDAPAdd ldaphost 389"
puts ""
return;
}
else {
set ldapServer [lindex $argv 0]
set ldapPort [lindex $argv 1]
LDAPAdd $ldapServer $ldapPort
return;
}
proc LDAPAdd {ldapServer ldapPort args} {
global AdminConfig AdminControl ldapServer ldapPort
set ldapServer lindex $args 0
set ldapPort lindex $args 1
global ldapUserRegistryId
# Get the LDAP user registry object from the security configuration
if { catch {$AdminConfig list LDAPUserRegistry} result } {
puts stdout "\$AdminConfig list LDAPUserRegistry caught an exception $result\n"
return
}
else {
if {$result != {}} {
set ldapUserRegistryId lindex $result 0
}
else {
puts stdout "\$AdminConfig list LDAPUserRegistry caught an exception $result\n"
return;
}
}
# Set the host and port values in Attrs2
set Attrs2 list list hosts list list list host
$ldapServer
list port $ldapPort
# Modify the LDAP configuration host object
$AdminConfig modify $ldapUserRegistryId $Attrs2
$AdminConfig save
}
#---------------------------------------------------------------
# Add ldap hostname and port
# wsadmin -f LDAPAdd.py arg1 arg2
#
# The script expects some parameters:
# arg1 - LDAP Server hostname
# arg2 - LDAP Server portnumber
#---------------------------------------------------------------
import java
#-------------------------------------------------------
# get the line separator and use to do the parsing
# since the line separator on different platform are different
lineSeparator = java.lang.System.getProperty('line.separator')
#-------------------------------------------------------------------------------
# add LDAP host
#-------------------------------------------------------------------------------
def LDAPAdd (ldapServer, ldapPort):
global AdminConfig, lineSeparator, ldapUserRegistryId
try:
ldapObject = AdminConfig.list("LDAPUserRegistry")
if len(ldapObject) == 0:
print "LDAPUserRegistry ConfigId was not found\n"
return
ldapUserRegistryId = ldapObject.split(lineSeparator)[0]
print "Got LDAPUserRegistry ConfigId is " + ldapUserRegistryId + "\n"
except:
print "AdminConfig.list('LDAPUserRegistry') caught an exception\n"
try:
secMbeans = AdminControl.queryNames('WebSphere:type=SecurityAdmin,*')
if len(secMbeans) == 0:
print "Security Mbean was not found\n"
return
secMbean = secMbeans.split(lineSeparator)[0]
print "Got Security Mbean is " + secMbean + "\n"
except:
print "AdminControl.queryNames('WebSphere:type=SecurityAdmin,*') caught an exception\n"
attrs2 = [["hosts", [[["host", ldapServer], ["port", ldapPort]]]]]
try:
AdminConfig.modify(ldapUserRegistryId, attrs2)
try:
AdminConfig.save()
print "Done setting up attributes values for LDAP User Registry"
print "Updated was saved successfully\n"
except:
print "AdminConfig.save() caught an exception\n"
except:
print "AdminConfig.modify(" + ldapUserRegistryId + ", " + attrs2 + ") caught an exception\n"
return
#-------------------------------------------------------------------------------
# Main entry point
#-------------------------------------------------------------------------------
if len(sys.argv) < 2 or len(sys.argv) > 3:
print("LDAPAdd: this script requires 2 parameters: LDAP server hostname and LDAP server port number\n")
print("e.g.: LDAPAdd ldaphost 389\n")
sys.exit(1)
else:
ldapServer = sys.argv[0]
ldapPort = sys.argv[1]
LDAPAdd(ldapServer, ldapPort)
sys.exit(0)