Dump TNSNAMES.ORA from ActiveDirectory

Having all connections string in ActiveDirectory is nice, but maybe you need sometimes to push it to an external system (e.g. DMZ or Linux).

echo "# AD" > tnsnames.ora
$o = New-Object DirectoryServices.DirectorySearcher
$o.Filter = 'objectclass=orclNetService'
foreach ($p in $o.FindAll().Properties) {
[String]($p.name+"="+$p.orclnetdescstring) >> tnsnames.ora

goodies :mrgreen:

1 thought on “Dump TNSNAMES.ORA from ActiveDirectory

  1. Laurent Schneider

    the unix equivalency would b

    ldapsearch -D '' -o TLS_REQCERT=never -o ldif-wrap=no -LLL -H ldaps://ldap.example.com:6366 -b cn=oraclecontext,DC=example,DC=com objectclass=orclservice cn orclnetdescstring |
    awk -F": " '/cn/{cn=$2}/orclnetdescstring/{orclnetdescstring=$2}/^$/{printf "%s.example.com=%s\n",cn,orclnetdescstring}'

Comments are closed.