LDAP Object works on a workstation but not a server
Posted on 2008-11-03
I am trying to access Active Directory via ADSystemInfo and LDAP object in a classic ASP page using VBScript. It checks the current user accessing the intranet site and pulls information accordingly. Different pages use different information, and it's not the issue anyways. I have the following code on my workstation (running IIS5.1 on Windows XP Pro SP2) and on our server (running IIS6.0 and Windows Server 2003 R2). It works perfect on my workstation with people hitting it from other workstations. It doesn't work for anyone accessing it on the server. The code and error is below:
Set ADSysInfo = CreateObject("ADSystemInfo")
Set CurrentUser = GetObject("LDAP://" & AdSysInfo.UserName)
varstrLogon = CurrentUser.userPrincipalName
Microsoft VBScript runtime error '800a01b6'
Object doesn't support this property or method: 'userPrincipalName'
As far as I can tell, IIS is set up identically on both servers, except for the differences with 6.0 and 5.1. I am using windows authentication and not allowing anonymous login because it's an intranet site. We have other pages running and they all work.
These lines don't work also(they break with the same error:
Response.Write("sAMAccountName = " & CurrentUser.sAMAccountName & "<br />")
Response.Write("LDAPDisplayName = " & CurrentUser.LDAPDisplayName & "<br />")
Response.Write("DisplayName = " & CurrentUser.DisplayName & "<br />")
Response.Write("AssocNTAccount = " & CurrentUser.AssocNTAccount & "<br />")
These lines don't break, but they don't return any value:
Response.Write("AssociatedName = " & CurrentUser.AssociatedName & "<br />")
Response.Write("AssociatedDomain = " & CurrentUser.AssociatedDomain & "<br />")
Any ideas on what to look for and why it would not work on the server, but works fine on the workstation?