Solved

LDAP query for SQL databses in AD

Posted on 2006-06-28
9
1,294 Views
Last Modified: 2010-08-05
I have an AD environment which has many rogue servers and services attached. I am needing to query AD for various databases: SQL, Oracle and DB2. I am unsure if any are registered in AD, but would like to look. I need some guidance on querying AD for registered databases.

Also, if there is a good MSDN (or other) resource for delving into the area of database registration with AD, I'd appreciate a point in the right direction.

Thank you,
John Darby
0
Comment
Question by:johndarby
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
9 Comments
 
LVL 16

Expert Comment

by:MohanKNair
ID: 17007107
Active Directory is a hierarchial database. The command line tool ldapsearch can be used to query active directory. This can be done from other systems like linux or unix box. Also there are tools which does LDAP queries.

Query Active Directory from the iSeries
http://www.itjungle.com/fhg/fhg061505-story01.html

Querying Active Directory using .NET classes and LDAP queries
http://www.codeproject.com/dotnet/activedirquery.asp


Also see these links about AD
Windows 2000 Active Directory
http://labmice.techtarget.com/activedirectory/default.htm

Oracle and Active Directory
http://dizwell.com/main/content/view/100/154/

Installing and Configuring Windows 2000 or 2003 DNS to Support Active Directory
http://www.oucs.ox.ac.uk/windows/active/dns/index.xml?style=printable
0
 
LVL 3

Expert Comment

by:tnapolitano
ID: 17007169
It sounds like you want to search your network for databases and create an inventory of sanctioned/rogue DB's. Is that correct?

Active Directory is a directory, a catalog. Rogue databases may not necessarily be apart of your AD structure. Databases could reside on standalone systems.

What I would do is start with a port scan of the network (get some kind of sign-off/approval first).

One port scan utility (in my mind, the only one) is NMap (www.insecure.org).

SQL ports include MSSQL:1434, Oracle:1525, DB2:523, MySQL:3306. Start with those.





0
 
LVL 16

Expert Comment

by:MohanKNair
ID: 17007293
Using PL/SQL it is possible to query LDAP

DBMS_LDAP - Accessing LDAP From PL/SQL
http://www.oracle-base.com/articles/9i/LDAPFromPLSQL9i.php

Building a Simple SQL Interface to any LDAP Server
http://www.oriole.com/SQL2LDAP.html

0
Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
LVL 3

Expert Comment

by:tnapolitano
ID: 17008368
LDAP queries are well and good, but there's no reason an unauthorized sql server would necessarily show up in Active Directory.

AD is a directory. A SQL Server is a system that an administrator would join to the domain, place in the directory. There is an Active Directory database (Ntds.dit) which provides the physical storage of all objects in the forest.

So, again, if it was me, I would start my search/inventory of SQL systems by port scanning. Next, Network Sniffing. Then ODBC sniffing (definately try to secure those ODBC connections, as all rx/tx are in clear-text).

0
 
LVL 1

Author Comment

by:johndarby
ID: 17010708
I have been doing just that. However, I am looking for an LDAP query (will use it in ADUC) which will show me all registered databases in AD.

Thank you for your reply!

John
0
 
LVL 3

Accepted Solution

by:
tnapolitano earned 500 total points
ID: 17011542

Here is a link to vbscript that can search AD for instances of published MSSQL databases.
http://www.sqlmag.com/Article/ArticleID/41841/sql_server_41841.html

Ostensibly, the code is about publishing databases in AD programatically, but the scripts can also be used to search.

This, again, is dependent on the databases being published in AD in the first place.
0
 
LVL 1

Author Comment

by:johndarby
ID: 17012011
Thanks for the link...I am off to work, now!

John
0
 
LVL 1

Author Comment

by:johndarby
ID: 17013004
I tried a custom query using the objectClass specified in the VBS file. Here is the query I formed...

(&(&(objectClass=mS-SQL-SQLServer)(DC=adi,DC=swedish,DC=org)))

However, this doesn't seem to produce any results. My Spotlight on SQL Enterprise finds registered SQL databases with no problem, but the interface doesn't reveal the LDAP queries it uses to acruire this data.

Any idea on correcting the above query to show registered SQL databases?

Thanks,
John
0
 
LVL 3

Expert Comment

by:tnapolitano
ID: 17013369

Try something like this:

objCommand.CommandText = "Select displayName from 'LDAP://CN=MS-SQL-SQLServer,CN=*,OU=<ComputersOU>,DC=adi,DC=swedish,DC=org'




Links:

sp_ActiveDirectory_SCP (Transact-SQL)
http://msdn2.microsoft.com/en-us/library/ms189776.aspx

http://technet2.microsoft.com/WindowsServer/en/Library/8127f5ed-4e05-4822-bfa9-402ceede47441033.mspx?mfr=true
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question