Link to home
Start Free TrialLog in
Avatar of Steven O'Neill
Steven O'NeillFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Question for Silvers5: The Active Directory datatype cannot be converted to/from a native DS datatype

Silvers5

You answered a question at: https://www.experts-exchange.com/questions/20187919/The-Active-Directory-datatype-cannot-be-converted-to-from-a-native-DS-datatype.html

I was hoping you'd be able to help me out with a similar problem.

I have my web server (W2K) running an AD query script that was working great until this morning when our network decided to have a little Monday morning breakdown! Now the script is no longer working and I'm getting the error listed in the question title.

I'm not sure what you mean at the bottom of the page but my box is logged in as an Server Admin on my machine which is located on the INTRANET domain. The AD is located on the SCOTLAND domain. I've tried restarting IIS Admin and WWW Services on my web server but this hasn't fixed the problem. Is there something else that I need to do?
ASKER CERTIFIED SOLUTION
Avatar of Michel Sakr
Michel Sakr
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Steven O'Neill

ASKER

Thanx Silvers5 but I've already tried that. Here is my code:

<%
on error resume next

      strLogonID = Request.Servervariables("LOGON_USER")

      If InStr(strLogonID, "\") > 0 Then
            strLogonID = LCase(Right(strLogonID, InStr(strLogonID, "\") - 2))
      End If
      
      id = LCase(strLogonID)

    Set User = GetObject("WinNT://scotland/" & id & "")
      Fullname = User.Fullname

'###### Pathway to use to Active Directory ######
testpath = "LDAP://CN=" & FullName & ",OU=\#Scots Users,DC=scotland,DC=co,DC=uk"
set usr = GetObject(testpath)

'###### Flush any cache held ######
usr.GetInfo

'###### Active Directory variables ######
strName = usr.get("givenName") '###### Users Christian Name ######
strSurname = usr.get("sn") '###### Users Surname ######
strInitials = usr.get("initials") '###### Users Initials ######
displayName = usr.get("displayName") '###### Full Display Name ######
strAddress = usr.get("StreetAddress") '###### Address Information ######
strRoom = usr.get("PhysicalDeliveryOfficeName") '###### Room/Area Information ######
secretary = usr.get("secretary") '###### Secrectary/Assistant ######
strTitle = usr.get("title") '###### Job Title ######
strTelephone = usr.get("telephoneNumber") '###### Official Intneral Telephone Number ######
strFax = usr.get("facsimileTelephoneNumber") '###### Fax Number ######
mobile = usr.get("mobile") '###### Mobile Number ######
telephoneAssistant = usr.get("telephoneAssistant") '###### Telephone Assistant ######
strDepartment = usr.get("department") '###### Department ######
strCC = usr.get("ExtensionAttribute1") '###### COST Centre ######
strBuilding = usr.get("ExtensionAttribute2") '###### Building ######
strDivision = usr.get("ExtensionAttribute3") '###### Division ######
strBranch = usr.get("ExtensionAttribute4") '###### Branch ######
ExtensionAttribute5 = usr.get("ExtensionAttribute5") '###### PC Item Number ######
ExtensionAttribute6 = usr.get("ExtensionAttribute6") '###### External Telephone Number ######
strGroup = usr.get("ExtensionAttribute7") '###### Group ######
othertelephone = usr.get("othertelephone") '###### GTN Telephone Number ######
samaccountname = usr.get("samaccountname") '###### User ID ######
adspath = usr.get("adspath") '###### Pathway to AD? ######
strFullName = usr.get("cn") '###### Full Display Name ######
strMail = usr.get("mail") '###### E-Mail Address ######
strManager = usr.get("manager")                                          '###### Reporting Officer ######
'###### End Active Directory variables ######

set usr = nothing

Response.Write      "Firstname = " & strName & "<br />"
Response.Write      "Surname = " & strSurname & "<br />"
Response.Write      "initials = " & strInitials & "<br />"
Response.Write      "displayName = " & displayName & "<br />"
Response.Write      "StreetAddress = " & strAddress & "<br />"
Response.Write      "PhysicalDeliveryOfficeName = " & strRoom & "<br />"
Response.Write      "secretary = " & secretary & "<br />"
Response.Write      "title = " & strTitle & "<br />"
Response.Write      "telephoneNumber = " & strTelephone & "<br />"
Response.Write      "facsimileTelephoneNumber = " & strFax & "<br />"
Response.Write      "mobile = " & mobile & "<br />"
Response.Write      "telephoneAssistant = " & telephoneAssistant & "<br />"
Response.Write      "department = " & strDepartment & "<br />"
Response.Write      "ExtensionAttribute1 = " & strCC & "<br />"
Response.Write      "ExtensionAttribute2 = " & strBuilding & "<br />"
Response.Write      "ExtensionAttribute3 = " & strDivision & "<br />"
Response.Write      "ExtensionAttribute4 = " & strBranch & "<br />"
Response.Write      "ExtensionAttribute5 = " & ExtensionAttribute5 & "<br />"
Response.Write      "ExtensionAttribute6 = " & ExtensionAttribute6 & "<br />"
Response.Write      "ExtensionAttribute7 = " & strGroup & "<br />"
Response.Write      "othertelephone = " & othertelephone & "<br />"
Response.Write      "samaccountname = " & samaccountname & "<br />"
Response.Write      "adspath = " & adspath & "<br />"
Response.Write      "FullName = " & strFullName & "<br />"
Response.Write      "e-mail = " & strMail & "<br />"
Response.Write      "strManager = " & strManager & "<br />"

If Err.Number <> 0 Then
      GetInfo = False
      Response.Write(Err.Number & ": " & Err.Description) 'always get "The Active Directory datatype cannot be converted to/from a native DS datatype"
      Err.Clear
  Else
      GetInfo = True
  End If
%>

As mentioned it was working fine until Monday morning when our entire network appeared to have a nervous breakdown (I'm not on the networking side so I'm not sure entirely what happened).

I'm currently logged on the INTRANET domain and our PDC is on the SCOTLAND domain. This was working fine. I've also stopped and restarted IIS Admin and WWW Services but this hasn't influenced anything. Any help is appreciated as always.

Points upped as this is a really urgent problem.

Cheers
Avatar of deighc
deighc

I suggest you turn off your error handling whilst working thru this problem. It's not clear to me exactly where the error is occuring because you're moving right past it with your error handler.

Is the error occuring when creating the User or usr objects or is the error occurring when you use the 'get' method to read some information from the usr object?

Perhaps one or more of the user attributes you're requesting has had its name changed. If you have an LDAP browser look at the AD structure and check that you're using the correct property names.

If the error is occuring whilst creating your usr object, again use an LDAP browser to check that your LDAP query is correct (most LDAP browsers will let you browse to an object then view the query path to that object).

If you don't already have an LDAP browser try the free version of Softerra LDAP Browser. Seems to work OK.

http://www.ldapbrowser.com/download/index.php
Thanx deighc

Asked the network boys to look at the attributes to see if any have been renamed but this seems unlikely.

I've seen this LDAP browser before and I have it installed but haven't gotten around to trying it out yet so now may be a good time to do so!

The error comes in when I'm trying to query one of the custom attributes. When I turn on the on error code above the first field that isn't populated is the displayName field that is supposed to pick up usr.get("displayName"). The actual User object works fine and doesn't need tweaking.

I had this problem previously and simply stopping and restarting IIS Admin and WWW on my web server appeared to fix the problem but not this time around.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Also your memebr might not be synchronising well on the domian (no dns entry or dns.. or else) try to rejoin the domain.. or try to restart the server
What Server should be restarted? My web server or the one with AD?
Problem solved (I hope). The problem appears to be caused by the usr.GetInfo call in my code. This appears to have been corrupting the very thing it was supposed to be refreshing. Removing this code has allowed the AD query to work again.

Not entirely sure why this would be the case and I'd appreciate any insight others have of this but I'm splitting the points 70/30 for Silvers5 and deighc (there are 2 AD properties that don't exist either!)

Thanx for all your help with this guys but if you do have anymore insight into this problem then it's greatly appreciated.