Index: server/common/oursrc/whoisd/whoisd.tac
===================================================================
--- server/common/oursrc/whoisd/whoisd.tac	(revision 528)
+++ server/common/oursrc/whoisd/whoisd.tac	(revision 627)
@@ -2,5 +2,6 @@
 from twisted.internet import protocol, reactor, defer
 from twisted.protocols import basic
-import os, sys, glob
+import ldap, ldap.filter
+import os, sys, pwd, glob
 
 class WhoisProtocol(basic.LineReceiver):
@@ -13,6 +14,9 @@
 class WhoisFactory(protocol.ServerFactory):
     protocol = WhoisProtocol
-    def __init__(self, vhostDir):
+    def __init__(self, vhostDir, ldap_URL, ldap_base):
         self.vhostDir = vhostDir
+        self.ldap_URL = ldap_URL
+        self.ldap = ldap.initialize(self.ldap_URL)
+        self.ldap_base = ldap_base
         self.vhosts = {}
         self.rescanVhosts()
@@ -40,5 +44,5 @@
                 docroot = parts[0]
             elif command == "</VirtualHost>":
-                d = {'locker': locker, 'docroot': docroot, 'canonical': hostnames[0]}
+                d = {'locker': locker, 'apacheDocumentRoot': docroot, 'apacheServerName': hostnames[0]}
                 for h in hostnames: vhosts[h] = d
                 hostnames = []
@@ -53,10 +57,29 @@
 #        else:
 #            return vhost + ".mit.edu"
+    def searchLDAP(self, vhost):
+        results = self.ldap.search_s(self.ldap_base, ldap.SCOPE_SUBTREE,
+            ldap.filter.filter_format(
+                '(|(apacheServername=%s)(apacheServerAlias=%s))', (vhost,)*2))
+        if len(results) >= 1:
+            result = results[0]
+            attrs = result[1]
+            for attr in ('apacheServerName','apacheDocumentRoot', 'apacheSuexecUid', 'apacheSuexecGid'):
+                attrs[attr] = attrs[attr][0]
+            user = pwd.getpwuid(int(attrs['apacheSuexecUid']))
+            if user:
+                attrs['locker'] = user.pw_name
+            else:
+                attrs['locker'] = None
+            return attrs
+        else:
+            return None
     def getWhois(self, vhost):
         vhost = self.canonicalize(vhost)
         info = self.vhosts.get(vhost)
+        if not info:
+            info = self.searchLDAP(vhost)
         if info:
             ret = "Hostname: %s\nAlias: %s\nLocker: %s\nDocument Root: %s" % \
-                (info['canonical'], vhost, info['locker'], info['docroot'])
+                (info['apacheServerName'], vhost, info['locker'], info['apacheDocumentRoot'])
         else:
             ret = "No such hostname"
@@ -64,5 +87,6 @@
 
 application = service.Application('whois', uid=99, gid=99)
-factory = WhoisFactory("/etc/httpd/vhosts.d")
+factory = WhoisFactory("/etc/httpd/vhosts.d",
+    "ldap://localhost", "ou=VirtualHosts,dc=scripts,dc=mit,dc=edu")
 internet.TCPServer(43, factory).setServiceParent(
     service.IServiceCollection(application))
