Install LDAP Configuration Details into WAS.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 | #
# Install LDAP Settings.
#
####################################################################
# Patrick Finnegan 19/09/2005. V1.
####################################################################
#-------------------------------------------------------------------------------
# Get List LDAP Registries.
#-------------------------------------------------------------------------------
proc getLDAPUserRegistryId {} {
global AdminConfig
puts "\n## List Registry Details ##\n"
# Note: IBM advise that there can only be one ldap server per cell.
if { [ catch { $AdminConfig list LDAPUserRegistry } r ] == 0 } {
set LDAPUserRegistryId $r
foreach e $r {
puts [ format "\n%-10s %-50s\n" "Registry:" $e ]
catch { $AdminConfig showAttribute $e baseDN } r
puts [ format "%-5s %-20s %-50s" " " baseDN $r ]
catch { $AdminConfig showAttribute $e bindDN } r
puts [ format "%-5s %-20s %-50s" " " bindDN $r ]
catch { $AdminConfig showAttribute $e bindPassword } r
puts [ format "%-5s %-20s %-50s" " " bindPassword $r ]
catch { $AdminConfig showAttribute $e hosts } hosts
puts [ format "%-5s %-20s %-50s" " " hosts $hosts ]
catch { $AdminConfig showAttribute $e ignoreCase } r
puts [ format "%-5s %-20s %-50s" " " ignoreCase $r ]
catch { $AdminConfig showAttribute $e limit } r
puts [ format "%-5s %-20s %-50s" " " limit $r ]
catch { $AdminConfig showAttribute $e monitorInterval } r
puts [ format "%-5s %-20s %-50s" " " monitorInterval $r ]
catch { $AdminConfig showAttribute $e properties } r
puts [ format "%-5s %-20s %-50s" " " properties $r ]
catch { $AdminConfig showAttribute $e realm } r
puts [ format "%-5s %-20s %-50s" " " realm $r ]
catch { $AdminConfig showAttribute $e type } r
puts [ format "%-5s %-20s %-50s" " " type $r ]
catch { $AdminConfig showAttribute $e reuseConnection } r
puts [ format "%-5s %-20s %-50s" " " reuseConnection $r ]
catch { $AdminConfig showAttribute $e searchTimeout } r
puts [ format "%-5s %-20s %-50s" " " searchTimeout $r ]
catch { $AdminConfig showAttribute $e serverId } r
puts [ format "%-5s %-20s %-50s" " " serverId $r ]
catch { $AdminConfig showAttribute $e serverPassword } r
puts [ format "%-5s %-20s %-50s" " " serverPassword $r ]
catch { $AdminConfig showAttribute $e sslConfig } r
puts [ format "%-5s %-20s %-50s" " " sslConfig $r ]
catch { $AdminConfig showAttribute $e sslEnabled } r
puts [ format "%-5s %-20s %-50s\n" " " sslEnabled $r ]
catch { $AdminConfig showAttribute $e searchFilter } LDAPSearchFilterId
puts [ format "%-5s %-20s %-50s" " " LDAPSearchFilterId $LDAPSearchFilterId ]
catch { getLDAPSearchFilter $LDAPSearchFilterId } r
lappend hostList $hosts
}
} else {
puts "\nproblem accessing LDAP user registry ID.\n"
puts $r
puts "************************************\n"
return -code error $r
}
lappend registryList $LDAPUserRegistryId
return [ list $registryList $hostList $LDAPSearchFilterId ]
}
#-------------------------------------------------------------------------------
# For existing LDAP server get search filter details.
#-------------------------------------------------------------------------------
proc getLDAPSearchFilter { LDAPSearchFilterId } {
global AdminConfig
puts "\n## List Ldap Search Filter ##\n"
foreach e $LDAPSearchFilterId {
catch { $AdminConfig showAttribute $LDAPSearchFilterId certificateFilter } r
puts [ format "%-5s %-20s %-50s" " " certificateFilter $r ]
catch { $AdminConfig showAttribute $LDAPSearchFilterId certificateMapMode} r
puts [ format "%-5s %-20s %-50s" " " certificateMapMode $r ]
catch { $AdminConfig showAttribute $LDAPSearchFilterId groupFilter } r
puts [ format "%-5s %-20s %-50s" " " groupFilter $r ]
catch { $AdminConfig showAttribute $LDAPSearchFilterId groupIdMap } r
puts [ format "%-5s %-20s %-50s" " " groupIdMap $r ]
catch { $AdminConfig showAttribute $LDAPSearchFilterId groupMemberIdMap } r
puts [ format "%-5s %-20s %-50s" " " groupMemberIdMap $r ]
catch { $AdminConfig showAttribute $LDAPSearchFilterId userFilter } r
puts [ format "%-5s %-20s %-50s" " " userFilter $r ]
catch { $AdminConfig showAttribute $LDAPSearchFilterId userIdMap } r
puts [ format "%-5s %-20s %-50s" " " userIdMap $r ]
}
}
#-------------------------------------------------------------------------------
# Delete any existing ldap host server definitions before defining a new one.
#-------------------------------------------------------------------------------
proc deleteHosts { hosts } {
global AdminConfig
puts "\n## Delete Existing Hosts ##\n"
# delete existing ldap host server ids or host modification will duplicate ids.
# extract host sublist from list
set hosts [ join $hosts ]
foreach hostId $hosts {
if { [ catch { $AdminConfig remove $hostId } r ] == 0 } {
puts [ format "%-5s %-20s %-50s" " " "Removed hostId" $hostId ]
return $r
} else {
puts "\nproblem removing host $hostId. \n"
puts $r
puts "************************************\n"
return -code error $r
}
}
}
#-------------------------------------------------------------------------------
# setup attribute values for LDAPUserRegistry using LDAPUserRegistry ConfigId
#-------------------------------------------------------------------------------
proc doLDAPUserRegistry { ldapServer \
ldapServerId \
ldapPassword \
ldapPort \
domainHostname \
baseDN \
LDAPUserRegistryId \
LDAPSearchFilterId } {
global AdminConfig
puts "\n## Modify LDAP Registry Details ##\n"
set serverId [ list serverId $ldapServerId ]
set serverPassword [ list serverPassword $ldapPassword ]
set realm [ list realm $ldapServer:$ldapPort ]
set type [ list type {CUSTOM} ]
set baseDN [ list baseDN $baseDN ]
set reuseConnection [ list reuseConnection true ]
set ignoreCase [ list ignoreCase true ]
set host [ list host $ldapServer ]
set port [ list port $ldapPort ]
set hostsList [ list [ list $host $port ] ]
set hosts [ list hosts $hostsList ]
set attrs [ list $serverId \
$serverPassword \
$realm \
$type \
$baseDN \
$reuseConnection \
$ignoreCase \
$hosts
]
puts " ATTRS = $attrs"
if { [ catch { $AdminConfig modify $LDAPUserRegistryId $attrs } r ] == 0 } {
return $r
} else {
puts "\nproblem updating LDAP $LDAPUserRegistryId. \n"
puts $r
puts "************************************\n"
return -code error $r
}
}
#-------------------------------------------------------------------------------
# setup attribute values for LDAPSearchFilterId using LDAPSearchFilterId ConfigId
#-------------------------------------------------------------------------------
proc modifyLDAPSearchFilterId { certificateMapMode \
groupFilter \
groupIdMap \
groupMemberIdMap \
userFilter \
userIdMap \
LDAPSearchFilterId } {
global AdminConfig
puts "\n## Modify LDAP Filter Details ##\n"
# ldap mappings are [listed] to avoid special character quoting problems.
set certificateMapMode [ list certificateMapMode [ join $certificateMapMode ] ]
set groupFilter [ list groupFilter [ join $groupFilter ] ]
set groupIdMap [ list groupIdMap [ join $groupIdMap ] ]
set groupMemberIdMap [ list groupMemberIdMap [ join $groupMemberIdMap ] ]
set userFilter [ list userFilter [ join $userFilter ] ]
set userIdMap [ list userIdMap [ join $userIdMap ] ]
set attrs [ list $certificateMapMode \
$groupFilter \
$groupIdMap \
$groupMemberIdMap \
$userFilter \
$userIdMap
]
if { [ catch { $AdminConfig modify $LDAPSearchFilterId $attrs } r ] == 0 } {
return $r
} else {
puts "\nproblem updating LDAP $LDAPSearchFilterId. \n"
puts $r
puts "************************************\n"
return -code error $r
}
}
####################################################################
# Main Control.
####################################################################
puts "\n argc = $argc \n"
if {$argc < 5} {
return -code error "error - no arguments supplied. Supply server name"
puts "no arguments"
}
# if the ldap search mappings contain system characters [ list ] mappings.
set ldapServer [ lindex $argv 0 ]
set ldapServerId [ lindex $argv 1 ]
set ldapPassword [ lindex $argv 2 ]
set ldapPort [ lindex $argv 3 ]
set domainHostname [ lindex $argv 4 ]
set baseDN [ lindex $argv 5 ]
set certificateMapMode "EXACT_DN"
set groupFilter "(&(|(|(objectclass=groupOfNames)(objectclass=groupOfUniqueNames)(objectclass=top))(objectclass=groupOfURLs))(cn=%v))"
set groupIdMap "*:cn"
set groupMemberIdMap "groupOfNames:member;groupOfUniqueNames:uniqueMember"
set userFilter "(&(cn=%v)(|(objectclass=ABC)(objectclass=DEF)(objectclass=person)))"
set userIdMap "*.cn"
set nodeName [ $AdminControl getNode ]
set cellName [ $AdminControl getCell ]
puts "ldapServer = $ldapServer "
puts "ldapServerId = $ldapServerId "
puts "ldapPassword = $ldapPassword "
puts "ldapPort = $ldapPort "
puts "domainHostname = $domainHostname "
puts "baseDN = $baseDN "
puts "nodeName = $nodeName "
puts "cellName = $cellName "
puts "certificateMapMode = $certificateMapMode "
puts "groupFilter = $groupFilter "
puts "groupIdMap = $groupIdMap "
puts "groupMemberIdMap = $groupMemberIdMap "
puts "userFilter = $userFilter "
puts "userIdMap = $userIdMap "
#######################################################################
# If the ldap server host definition already exists do not delete because it may be in use by some of the installed applications. Modify instead.
#######################################################################
if { [ catch { getLDAPUserRegistryId } r ] == 0 } {
puts "\n Registry $r \n"
set LDAPUserRegistryId [ lindex [ lindex $r 0 ] 0 ]
set hostList [ lindex $r 1 ]
set LDAPSearchFilterId [ lindex $r 2 ]
} else {
return -code error $r
}
# if the host list contains no elements or only null elements skip delete.
#puts "\n hostlist = $hostList \n"
if { [ lindex [ eval join $hostList ] 0 ] == "" } {
puts "\nno hosts\n"
set continue true
} else {
if { [ catch { deleteHosts $hostList } r ] == 0 } {
set continue true
} else {
return -code error $r
}
}
if { [ catch { doLDAPUserRegistry $ldapServer \
$ldapServerId \
$ldapPassword \
$ldapPort \
$domainHostname \
$baseDN \
$LDAPUserRegistryId \
$LDAPSearchFilterId \
} r ] == 0 } {
if { [ catch { modifyLDAPSearchFilterId $certificateMapMode \
$groupFilter \
$groupIdMap \
$groupMemberIdMap \
$userFilter \
$userIdMap \
$LDAPSearchFilterId } r ] == 0 } {
puts "\n## Admin Config Save ##\n"
catch { $AdminConfig save } r
puts $r
} else {
return -code error $r
}
} else {
return -code error $r
}
####################################################################
# List servers to verify install.
####################################################################
if { [ catch { getLDAPUserRegistryId } r ] == 0 } {
set continue true
} else {
return -code error $r
}
|
Tags: websphere