By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,275 Members | 1,937 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,275 IT Pros & Developers. It's quick & easy.

ASP LDAP Query working on localhost but not webserver

P: n/a
Sorry everyone,

NOTE: I have posted this question to another site but unfortunately,
am not getting the answers I need only because those helping haven't
worked with ASP.

I am in desperate need of a fix. I am using classic asp and making a
connection to LDAP server using SQL code under IIS 5 on my localhost
and it works great. I have a form and form fields that pull from
active directory. Now, once I get the web team to deploy these files
to the webserver where all users will be able to run this app.(this
server is using IIS 6), my form fields show up blank. For the life of
me I cannot see what is wrong or different except the IIS version.
Also, I have gotten the IIS logs and they don't tell me anything.

Expand|Select|Wrap|Line Numbers
  1. UserSelect= instr(Session("User"),"\")
  2. user = Mid(Session("User"), UserSelect + 1, len(Session("User"))-
  3. UserSelect)
  4.  
  5. Set objConnection = CreateObject("ADODB.Connection")
  6. Set objCommand =   CreateObject("ADODB.Command")
  7. Set objCommand1 =   CreateObject("ADODB.Command")
  8. objConnection.Provider = "ADsDSOObject"
  9. objConnection.Open "Active Directory Provider"
  10. Set objCommand.ActiveConnection = objConnection
  11.  
  12. 'objCommand.Properties("Page Size") = 1
  13.  
  14. 'objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
  15.  
  16. objCommand.CommandText = _
  17.  
  18. "SELECT GivenName, mail, telephoneNumber FROM 'LDAP Server(hidden for
  19. security)' WHERE sAMAccountName ='" & user  & "'"
  20.  
  21. Set objRecordSet = objCommand.Execute
  22.  
Any ideas why it works locally but not on the webserver? Thanks.

Sep 15 '07 #1
Share this Question
Share on Google+
7 Replies


P: n/a
On Sep 15, 12:54 am, MrHelpMe <clintto...@hotmail.comwrote:
Sorry everyone,

NOTE: I have posted this question to another site but unfortunately,
am not getting the answers I need only because those helping haven't
worked with ASP.

I am in desperate need of a fix. I am using classic asp and making a
connection to LDAP server using SQL code under IIS 5 on my localhost
and it works great. I have a form and form fields that pull from
active directory. Now, once I get the web team to deploy these files
to the webserver where all users will be able to run this app.(this
server is using IIS 6), my form fields show up blank. For the life of
me I cannot see what is wrong or different except the IIS version.
Also, I have gotten the IIS logs and they don't tell me anything.

Expand|Select|Wrap|Line Numbers
  1. UserSelect= instr(Session("User"),"\")
  2. user = Mid(Session("User"), UserSelect + 1, len(Session("User"))-
  3. UserSelect)
  4. Set objConnection = CreateObject("ADODB.Connection")
  5. Set objCommand =   CreateObject("ADODB.Command")
  6. Set objCommand1 =   CreateObject("ADODB.Command")
  7. objConnection.Provider = "ADsDSOObject"
  8. objConnection.Open "Active Directory Provider"
  9. Set objCommand.ActiveConnection = objConnection
  10. 'objCommand.Properties("Page Size") = 1
  11. 'objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
  12. objCommand.CommandText = _
  13.  "SELECT GivenName, mail, telephoneNumber FROM 'LDAP Server(hidden for
  14. security)' WHERE sAMAccountName ='" & user  & "'"
  15. Set objRecordSet = objCommand.Execute
  16.  

Any ideas why it works locally but not on the webserver? Thanks.
Sorry I forgot to mention my iis security settings are Integrated
windows authentication. That's it.

Sep 15 '07 #2

P: n/a

"MrHelpMe" <cl********@hotmail.comwrote in message
news:11**********************@w3g2000hsg.googlegro ups.com...
On Sep 15, 12:54 am, MrHelpMe <clintto...@hotmail.comwrote:
>Sorry everyone,

NOTE: I have posted this question to another site but unfortunately,
am not getting the answers I need only because those helping haven't
worked with ASP.

I am in desperate need of a fix. I am using classic asp and making a
connection to LDAP server using SQL code under IIS 5 on my localhost
and it works great. I have a form and form fields that pull from
active directory. Now, once I get the web team to deploy these files
to the webserver where all users will be able to run this app.(this
server is using IIS 6), my form fields show up blank. For the life of
me I cannot see what is wrong or different except the IIS version.
Also, I have gotten the IIS logs and they don't tell me anything.

Expand|Select|Wrap|Line Numbers
  1. UserSelect= instr(Session("User"),"\")
  2. user = Mid(Session("User"), UserSelect + 1, len(Session("User"))-
  3. UserSelect)
  4. Set objConnection = CreateObject("ADODB.Connection")
  5. Set objCommand =   CreateObject("ADODB.Command")
  6. Set objCommand1 =   CreateObject("ADODB.Command")
  7. objConnection.Provider = "ADsDSOObject"
  8. objConnection.Open "Active Directory Provider"
  9. Set objCommand.ActiveConnection = objConnection
  10. 'objCommand.Properties("Page Size") = 1
  11. 'objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
  12. objCommand.CommandText = _
  13.  "SELECT GivenName, mail, telephoneNumber FROM 'LDAP Server(hidden for
  14. security)' WHERE sAMAccountName ='" & user  & "'"
  15. Set objRecordSet = objCommand.Execute

Any ideas why it works locally but not on the webserver? Thanks.

Sorry I forgot to mention my iis security settings are Integrated
windows authentication. That's it.
What are the security settings on the live web server. If it's integrated
security, have you tried it with your login, and is the login in the same
domain as your local system? If it's anonymous, the anonymous user context
will need sufficient privileges to access LDAP.

-Mark

Sep 16 '07 #3

P: n/a
On Sep 15, 10:42 pm, "Mark J. McGinty" <mmcgi...@spamfromyou.com>
wrote:
"MrHelpMe" <clintto...@hotmail.comwrote in message

news:11**********************@w3g2000hsg.googlegro ups.com...


On Sep 15, 12:54 am, MrHelpMe <clintto...@hotmail.comwrote:
Sorry everyone,
NOTE: I have posted this question to another site but unfortunately,
am not getting the answers I need only because those helping haven't
worked with ASP.
I am in desperate need of a fix. I am using classic asp and making a
connection to LDAP server using SQL code under IIS 5 on my localhost
and it works great. I have a form and form fields that pull from
active directory. Now, once I get the web team to deploy these files
to the webserver where all users will be able to run this app.(this
server is using IIS 6), my form fields show up blank. For the life of
me I cannot see what is wrong or different except the IIS version.
Also, I have gotten the IIS logs and they don't tell me anything.
Expand|Select|Wrap|Line Numbers
  1. UserSelect= instr(Session("User"),"\")
  2. user = Mid(Session("User"), UserSelect + 1, len(Session("User"))-
  3. UserSelect)
Expand|Select|Wrap|Line Numbers
  1.         
  2.                         
  3.                 Set objConnection = CreateObject("ADODB.Connection")
  4. Set objCommand =   CreateObject("ADODB.Command")
  5. Set objCommand1 =   CreateObject("ADODB.Command")
  6. objConnection.Provider = "ADsDSOObject"
  7. objConnection.Open "Active Directory Provider"
  8. Set objCommand.ActiveConnection = objConnection
  •  
  •         
  •                         
  •                 'objCommand.Properties("Page Size") = 1
  •  
  •         
  •                         
  •                 'objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
  •  
  •         
  •                         
  •                 objCommand.CommandText = _
  •  
  •         
  •                         
  •                  "SELECT GivenName, mail, telephoneNumber FROM 'LDAP Server(hidden for
  • security)' WHERE sAMAccountName ='" & user  & "'"
  •  
  •         
  •                         
  •                 Set objRecordSet = objCommand.Execute
  •  
  •  
  • Any ideas why it works locally but not on the webserver? Thanks.
    Sorry I forgot to mention my iis security settings are Integrated
    windows authentication. That's it.

    What are the security settings on the live web server. If it's integrated
    security, have you tried it with your login, and is the login in the same
    domain as your local system? If it's anonymous, the anonymous user context
    will need sufficient privileges to access LDAP.

    -Mark- Hide quoted text -

    - Show quoted text - Hi Mark,
    The security settings are integrated security. Not sure what you mean
    have I tried it with my login? The code is taking my windows NT login
    and passing that to the LDAP query for retrieval. So I think the
    answer to that is yes but no values are showing up. Yes the login is
    in the same domain as my local system. Any other ideas? Thanx for
    you help.

    Sep 16 '07 #4

    P: n/a

    "MrHelpMe" <cl********@hotmail.comwrote in message
    news:11**********************@n39g2000hsh.googlegr oups.com...
    On Sep 15, 10:42 pm, "Mark J. McGinty" <mmcgi...@spamfromyou.com>
    wrote:
    >"MrHelpMe" <clintto...@hotmail.comwrote in message

    news:11**********************@w3g2000hsg.googlegr oups.com...


    On Sep 15, 12:54 am, MrHelpMe <clintto...@hotmail.comwrote:
    Sorry everyone,
    >NOTE: I have posted this question to another site but unfortunately,
    am not getting the answers I need only because those helping haven't
    worked with ASP.
    >I am in desperate need of a fix. I am using classic asp and making a
    connection to LDAP server using SQL code under IIS 5 on my localhost
    and it works great. I have a form and form fields that pull from
    active directory. Now, once I get the web team to deploy these files
    to the webserver where all users will be able to run this app.(this
    server is using IIS 6), my form fields show up blank. For the life of
    me I cannot see what is wrong or different except the IIS version.
    Also, I have gotten the IIS logs and they don't tell me anything.
    >
    Expand|Select|Wrap|Line Numbers
    1. UserSelect= instr(Session("User"),"\")
    2. user = Mid(Session("User"), UserSelect + 1, len(Session("User"))-
    3. UserSelect)
    Expand|Select|Wrap|Line Numbers
    1.         
    2.                 >Set objConnection = CreateObject("ADODB.Connection")
    3. Set objCommand =   CreateObject("ADODB.Command")
    4. Set objCommand1 =   CreateObject("ADODB.Command")
    5. objConnection.Provider = "ADsDSOObject"
    6. objConnection.Open "Active Directory Provider"
    7. Set objCommand.ActiveConnection = objConnection
  •  
  •         
  •                 >'objCommand.Properties("Page Size") = 1
  •  
  •         
  •                 >'objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
  •  
  •         
  •                 >objCommand.CommandText = _
  •  
  •         
  •                 > "SELECT GivenName, mail, telephoneNumber FROM 'LDAP Server(hidden for
  • security)' WHERE sAMAccountName ='" & user  & "'"
  •  
  •         
  •                 >Set objRecordSet = objCommand.Execute
  •  
  •  
  • >Any ideas why it works locally but not on the webserver? Thanks.
    Sorry I forgot to mention my iis security settings are Integrated
    windows authentication. That's it.

    What are the security settings on the live web server. If it's
    integrated
    security, have you tried it with your login, and is the login in the same
    domain as your local system? If it's anonymous, the anonymous user
    context
    will need sufficient privileges to access LDAP.

    -Mark- Hide quoted text -

    - Show quoted text -
    Hi Mark,
    The security settings are integrated security. Not sure what you mean
    have I tried it with my login? The code is taking my windows NT login
    and passing that to the LDAP query for retrieval. Right... maybe your system is flagged as trusted for delegation and the web
    server is not?
    So I think the
    answer to that is yes but no values are showing up. Yes the login is
    in the same domain as my local system. Any other ideas? Thanx for
    you help.
    You don't show the code where you output the values of the recordset fields,
    are you sure the recordset is being opened? (Check its state property.)
    Have you examined the contents of the Connection.Errors collection? If you
    have errors disabled, comment the 'on error resume next' line to find out
    exactly where [and hopefully even why] the error is occurring.

    I suspect the issue has something to do with security, so if it was my
    project (barring any relevant info from error messages to the contrary) that
    is where I would look.

    -Mark


    Sep 16 '07 #5

    P: n/a
    On Sep 16, 3:08 pm, "Mark J. McGinty" <mmcgi...@spamfromyou.com>
    wrote:
    "MrHelpMe" <clintto...@hotmail.comwrote in message

    news:11**********************@n39g2000hsh.googlegr oups.com...


    On Sep 15, 10:42 pm, "Mark J. McGinty" <mmcgi...@spamfromyou.com>
    wrote:
    "MrHelpMe" <clintto...@hotmail.comwrote in message
    >news:11**********************@w3g2000hsg.googlegr oups.com...
    On Sep 15, 12:54 am, MrHelpMe <clintto...@hotmail.comwrote:
    Sorry everyone,
    NOTE: I have posted this question to another site but unfortunately,
    am not getting the answers I need only because those helping haven't
    worked with ASP.
    I am in desperate need of a fix. I am using classic asp and making a
    connection to LDAP server using SQL code under IIS 5 on my localhost
    and it works great. I have a form and form fields that pull from
    active directory. Now, once I get the web team to deploy these files
    to the webserver where all users will be able to run this app.(this
    server is using IIS 6), my form fields show up blank. For the life of
    me I cannot see what is wrong or different except the IIS version.
    Also, I have gotten the IIS logs and they don't tell me anything.
    Expand|Select|Wrap|Line Numbers
    1. UserSelect= instr(Session("User"),"\")
    2. user = Mid(Session("User"), UserSelect + 1, len(Session("User"))-
    3. UserSelect)
    Expand|Select|Wrap|Line Numbers
    1.         
    2.                         
    3.                 Set objConnection = CreateObject("ADODB.Connection")
    4. Set objCommand =   CreateObject("ADODB.Command")
    5. Set objCommand1 =   CreateObject("ADODB.Command")
    6. objConnection.Provider = "ADsDSOObject"
    7. objConnection.Open "Active Directory Provider"
    8. Set objCommand.ActiveConnection = objConnection
  •  
  •         
  •                         
  •                 'objCommand.Properties("Page Size") = 1
  •  
  •         
  •                         
  •                 'objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
  •  
  •         
  •                         
  •                 objCommand.CommandText = _
  •  
  •         
  •                         
  •                  "SELECT GivenName, mail, telephoneNumber FROM 'LDAP Server(hidden for
  • security)' WHERE sAMAccountName ='" & user  & "'"
  •  
  •         
  •                         
  •                 Set objRecordSet = objCommand.Execute
  •  
  •  
  • Any ideas why it works locally but not on the webserver? Thanks.
    Sorry I forgot to mention my iis security settings are Integrated
    windows authentication. That's it.
    What are the security settings on the live web server. If it's
    integrated
    security, have you tried it with your login, and is the login in the same
    domain as your local system? If it's anonymous, the anonymous user
    context
    will need sufficient privileges to access LDAP.
    -Mark- Hide quoted text -
    - Show quoted text -
    Hi Mark,
    The security settings are integrated security. Not sure what you mean
    have I tried it with my login? The code is taking my windows NT login
    and passing that to the LDAP query for retrieval.

    Right... maybe your system is flagged as trusted for delegation and the web
    server is not?
    So I think the
    answer to that is yes but no values are showing up. Yes the login is
    in the same domain as my local system. Any other ideas? Thanx for
    you help.

    You don't show the code where you output the values of the recordset fields,
    are you sure the recordset is being opened? (Check its state property.)
    Have you examined the contents of the Connection.Errors collection? If you
    have errors disabled, comment the 'on error resume next' line to find out
    exactly where [and hopefully even why] the error is occurring.

    I suspect the issue has something to do with security, so if it was my
    project (barring any relevant info from error messages to the contrary) that
    is where I would look.

    -Mark- Hide quoted text -

    - Show quoted text - O.k Mark,
    I think you are on to something. I forgot I had on error resume.....:
    ( so I removed the code. Now hopefully you could explain what is
    wrong as I am getting the error
    Microsoft VBScript runtime error '800a000d'

    Type mismatch Line 276.

    Line 276 is as follows....exactly what you wanted to see.
    Expand|Select|Wrap|Line Numbers
    1. <TD width="392"><INPUT type="text" name="RequestorFirstName" value="<
    2. %=Trim(objRecordSet("GivenName"))%>"></TD>
    3.  
    Can you see anything wrong because I can't? Also, why would it work
    on my localhost without error but not here? Thanks again for you
    help.

    Sep 17 '07 #6

    P: n/a
    [Please trim when responding]

    "MrHelpMe" wrote:
    Microsoft VBScript runtime error '800a000d'

    Type mismatch Line 276.

    Line 276 is as follows....exactly what you wanted to see.
    Expand|Select|Wrap|Line Numbers
    1. <TD width="392"><INPUT type="text" name="RequestorFirstName" value="<
    2. %=Trim(objRecordSet("GivenName"))%>"></TD>
    3.  
    The type mismatch probably comes from VBScript's Trim function, which
    requires a string. You used a notational shortcut for
    objRecordSet.Fields("GivenName").Value, which VBScript allows you to do
    because it supports default properties on ADODB.Recordset objects.

    Normally, this works great, but what if the recordset is empty, as I suspect
    yours is? What happens if you pass an object or a Null value to a function
    that requires a string?

    http://msdn2.microsoft.com/en-us/library/c623wz83.aspx

    Can you see anything wrong because I can't? Also, why would it work on
    my localhost without error but not here?
    Simple. If the recordset is empty, it will behave differently. Try disabling
    Integrated Windows Authentication on localhost, and you will probably see a
    similar error. I believe your AD query is not returning any records.
    --
    Dave Anderson

    Unsolicited commercial email will be read at a cost of $500 per message. Use
    of this email address implies consent to these terms.

    Sep 17 '07 #7

    P: n/a
    Hi Dave,

    "Normally, this works great, but what if the recordset is empty, as I
    suspect
    yours is? What happens if you pass an object or a Null value to a
    function
    that requires a string?"

    Actually, my recordset is not empty. It is taking the user session
    and using that to filter the AD Query and my name definitely comes up
    in the user session as I response.write the session. I will have a
    closer look at the code though.

    Sep 17 '07 #8

    This discussion thread is closed

    Replies have been disabled for this discussion.