PDA

View Full Version : Displaying Outlook distribution lists on Intranet


afranka
12-13-2005, 12:24 PM
Hi,

I have a vbscript which when run on a pc accesses and displays (in an annoying popup kind of way) a list of Outlook (exchange) distribution lists and their owners. I'd really like to list these on a basic web page.

The original vb code which works is below. I changed the wscript.echo statements to response.write but am not getting any joy. Am I missing something really silly?

I'd appreciate any suggestions you could offer.
Thanks!
a.

On Error Resume Next
Const ADS_SCOPE_SUBTREE = 2
OU = "'LDAP://DC=test,DC=com'"

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCOmmand.ActiveConnection = objConnection
objCommand.CommandText = _
"Select distinguishedName, displayName, msExchALObjectVersion from " & OU & " where objectClass='group' order by displayName"
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Timeout") = 360
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.Properties("Cache Results") = False
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
'wscript.echo objRecordSet.Fields("Name").Value
if objRecordSet.Fields("msExchALObjectVersion").Value <> "" then
wscript.echo
wscript.echo objRecordSet.Fields("displayName").Value
goManagedBy
end if
objRecordSet.MoveNext
Loop
Set objCOmmand.ActiveConnection = nothing
Set objRecordSet = nothing
Set objCommand = nothing
Set objConnection = nothing

Sub goManagedBy
Set objGroup = GetObject _
("LDAP://" & objRecordSet.Fields("distinguishedName").Value)
strManagedby = objGroup.Get("managedBy")
wscript.echo Mid(strManagedby,4,Instr(strManagedby, ",")-4)
'wscript.echo strManagedBy
End Sub

hinch
12-13-2005, 12:45 PM
could try installing outlook on the webserver with a dummy account just an idea

never tried ldap in asp so not entirely sure though i do know you can use the atapi stuff if outlook is installed on the machine its self.

afranka
12-13-2005, 01:09 PM
Thanks for replying!
I was hoping there might be an easier way?!

Maybe someone knows of a way?!

hinch
12-13-2005, 01:39 PM
do you have the active directory driver installed on the webserver since it looks like the code is behaving like a basic DB connection it'd require the AD driver also.

failing that you could always install a socket component and do socket queries against the ldap server.

afranka
12-13-2005, 02:14 PM
I'm guessing that the AD driver isn't installed. I'll see if I can find it on CD.
Alternatively, is the socket option easy?