Working from command line, but NOT in an ASP page. Why? 
Author Message
 Working from command line, but NOT in an ASP page. Why?

The main problem is the ASP page can not correctly
retrieve multi-value attribute (memberOf) from Exchange
Server.  (Single-value attribute works fine, see code
below.)

The following is ASP code (not working) and identical .vbs
code (working from command line.)  

ASP Code (not working)
================================================

 <%
    Const ADS_SCOPE_SUBTREE=2


    exchServer  = "exchangServerName"
    Set con = CreateObject("ADODB.Connection")
    Set Com = CreateObject("ADODB.Command")

    'Open a Connection object
    con.Provider = "ADsDSOObject"

    '------------------------------------
    ' Open the connection
    '-------------------------------------
    con.Open "Active Directory Provider"

    ' Create a command object on this connection
    Set Com.ActiveConnection = con

    '--------------------------------------------------
    ' set the query string
    '---------------------------------------------------
    adsPath = "LDAP://" & exchServer & ":389"

    Set oADs = GetObject(adsPath)

    Com.CommandText = "select ADsPath, uid, title,
givenName, sn, mail,
physicalDeliveryOfficeName,telephoneNumber,memberOf
from '" & adsPath & "' where mail ='" & searchAlias & "'"

    '-----------------------------------------
    'Set the preferences for Search
    '--------------------------------------
    Com.Properties("Page Size") = 100
    Com.Properties("Timeout") = 30 'seconds
    Com.Properties("searchscope") =
ADS_SCOPE_SUBTREE 'Define in ADS_SCOPEENUM
    Com.Properties("Cache Results") = False ' do not cache
the result, it results in less memory requirements

    '--------------------------------------------
    'Execute the query
    '--------------------------------------------
    Set rs = Com.Execute

    '--------------------------------------
    ' Navigate the record set
    '----------------------------------------

    If ( rs.EOF = False ) Then
      Response.Write "Alias     = " & rs.Fields
("UID").Value & "<br/>"
      Response.Write "Member Of = "
      Response.Write "TypeName(memberOf) is " & TypeName
(rs.Fields("memberOf").Value) & "<br/>"
      For Each item in rs.Fields("memberOf").Value
        adsPath_DL = adsPath & "/" & item
        Set oDL = GetObject(adsPath_DL)
        Response.Write oDL.cn
      Next

    End If

%>
========  END OF ASP CODE ====================

searchAlias.vbs
(Working from command line:

=================================================

    Set oArgs = wscript.Arguments

    if ( oArgs.Count <> 1 ) then
      wscript.echo "Usage exchsrch alias"
      wscript.echo "e.g cscript exchsrch.vbs andyhar"
      wscript.quit(0)
    end if

    Const ADS_SCOPE_SUBTREE=2

    searchAlia{ w y Dg? S? 0v
s = oArgs(0)
    exchServer  = "exchangeServerName"
    Set con = CreateObject("ADODB.Connection")
    Set Com = CreateObject("ADODB.Command")

    'Open a Connection object
    con.Provider = "ADsDSOObject"

    '------------------------------------
    ' Open the connection
    '-------------------------------------
    con.Open "Active Directory Provider"

    ' Create a command object on this connection
    Set Com.ActiveConnection = con

    '--------------------------------------------------
    ' set the query string
    '---------------------------------------------------

    adsPath = "LDAP://" & exchServer & ":389"

    Set oADs = GetObject(adsPath)

    Com.CommandText = "select ADsPath, uid, title,
givenName, sn, mail,
physicalDeliveryOfficeName,telephoneNumber,memberOf
from '" & adsPath & "' where mail ='" & searchAlias & "'"

    '-----------------------------------------
    'Set the preferences for Search
    '--------------------------------------
    Com.Properties("Page Size") = 100
    Com.Properties("Timeout") = 30 'seconds
    Com.Properties("searchscope") =
ADS_SCOPE_SUBTREE 'Define in ADS_SCOPEENUM
    Com.Properties("Cache Results") = False ' do not cache
the result, it results in less memory requirements

    '--------------------------------------------
    'Execute the query
    '--------------------------------------------
    Set rs = Com.Execute

    '--------------------------------------
    ' Navigate the record set
    '----------------------------------------

    If ( rs.EOF = False ) Then
      wscript.echo "Alias     = " & rs.Fields("UID").Value
      wscript.echo "Name      = " & rs.Fields
("givenName").Value & " " & rs.Fields("sn")
      wscript.echo "Title     = " & rs.Fields
("Title").Value
      wscript.echo "Office    = " & rs.Fields
("physicalDeliveryOfficeName").Value
      wscript.echo "Telephone = " & rs.Fields
("telephoneNumber").Value
      wscript.echo "Member Of = "
      wscript.echo "TypeName(memberOf) is " & TypeName
(rs.Fields("memberOf").Value)
      wscript.echo "TypeName(memberOf) is " & rs.Fields
("memberOf").Type
      For Each item in rs.Fields("memberOf").Value
        adsPath_DL = adsPath & "/" & item
        Set oDL = GetObject(adsPath_DL)
        wscript.echo oDL.cn
      Next
   End If
============ END OF searchAlias.vbs ==========

Any help would be greatly appreciated.

Dafang



Tue, 24 Aug 2004 13:21:09 GMT  
 Working from command line, but NOT in an ASP page. Why?
Try posing this question to the microsoft.public.scripting.VBScript newsgroup.


Thu, 26 Aug 2004 12:32:03 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. VBscript in ASP not working, but command line does

2. Memo field on ASP page - line breaks not appearing

3. Memo field on ASP page - line breaks not appearing

4. Memo field on ASP page - line breaks not appearing

5. Memo field on ASP page - line breaks not appearing

6. ASP page does not work?

7. WMI and ASP pages not working

8. ASP pages work in PWS but not in IIS

9. Passing values into and out of Command Line application *and* command line prompt in vbscript

10. Scripting command line applications & Command Line Prompting

11. Why command onsubmit not function in JavaScript

12. GS/GV Newbie: Learning to work with GhostScript from the command line

 

 
Powered by phpBB® Forum Software