So I've run into a rather confusing issue with a script I'm writing to update userWorkstations attribute. Below is a simplified version of what I'm doing (hopefully with no typos):
It works fine if the userWorkstation attribute is populated, but if it's empty I get an error:
If I run the code with a valid user DN that has information in the userWorkstation attribute, script works fine. If I run the code with a valid user DN that does not have any information in the userWorkstation attribute, the error above is returned and refers to strComps = objUser.Get("userWorkstations").
I tried using an If/Then statement with <> "" or IsNull() but that doesn't work either. Any suggestions other than an On Error Resume Next? I'd like to understand what is actually going on.
=================
There are 10 kinds of people in this world, those that understand binary and those that do not.
Code:
strUserDN = "CN=username,OU=Users,DC=xyz,DC=com"
Set objUser = GetObject("LDAP://" & strUserDN)
strUser = objUser.Get("samaccountname")
strComps = objUser.Get("userWorkstations")
WScript.Echo "User: " & strUser & vbCrLf & "Workstations: " & strComps
It works fine if the userWorkstation attribute is populated, but if it's empty I get an error:
Code:
Error: The directory property cannot be found in the cache
Code: 8000500D
Source: Active Directory
If I run the code with a valid user DN that has information in the userWorkstation attribute, script works fine. If I run the code with a valid user DN that does not have any information in the userWorkstation attribute, the error above is returned and refers to strComps = objUser.Get("userWorkstations").
I tried using an If/Then statement with <> "" or IsNull() but that doesn't work either. Any suggestions other than an On Error Resume Next? I'd like to understand what is actually going on.
=================
There are 10 kinds of people in this world, those that understand binary and those that do not.