Mike
05-03-2002, 02:44 AM
I'm writing a script to enumerate all the users in a particular container as well as specific attributes of that user. I'm querying an Active Directory Database. Here is my problem. (If my code looks rather ameteurish, it is :)
Option Explicit
Dim objDSE, strDefaultDN, strDN, objContainer, objChild, strInfo, strUser, objUser
Set objDSE = GetObject("LDAP://rootDSE")
strDefaultDN = "CN=Users," & objDSE.Get("defaultNamingContext")
strDN = InputBox("Enter the distinguished name of a container" & _
vbCrLf & "(e.g. " & strDefaultDN & ")", , strDefaultDN)
If strDN = "" Then WScript.Quit(1) 'user clicked Cancel
Set objContainer = GetObject("LDAP://" & strDN)
objContainer.Filter = Array("user")
For Each objChild In objContainer
strInfo = strInfo & objChild.Name & vbTab
objUser = objChild.Name
Call UserInfo(objUser)
strInfo = strInfo & objUser & vbCRLF
Next
Wscript.Echo strInfo
Sub UserInfo(objChild)
Dim objUser
Set objUser = GetObject("LDAP://" & objChild & ",CN=Users," & _
objDSE.Get("defaultNamingContext"))
objChild = objUser.Profile
Set objUser = Nothing
End Sub
'-------------
'End of Script
'-------------
I'm receiving an error that states the Active Directory property cannot be found in the cache, which pertains to line 30 (objChild = objUser.Profile)
If my implementation is wrong, the error is definitely right. But I've compared my implementation to another script performing a similar task, and everything adds up. The only properties I can access from objUser are Name and Description.
Ultimately, my goal is to enumerate all users from a particular container, and show the Profile property for each user. Doesn't seem like a difficult task! :)
Any help concerning this would be much appreciated! Thanks.
_M
Option Explicit
Dim objDSE, strDefaultDN, strDN, objContainer, objChild, strInfo, strUser, objUser
Set objDSE = GetObject("LDAP://rootDSE")
strDefaultDN = "CN=Users," & objDSE.Get("defaultNamingContext")
strDN = InputBox("Enter the distinguished name of a container" & _
vbCrLf & "(e.g. " & strDefaultDN & ")", , strDefaultDN)
If strDN = "" Then WScript.Quit(1) 'user clicked Cancel
Set objContainer = GetObject("LDAP://" & strDN)
objContainer.Filter = Array("user")
For Each objChild In objContainer
strInfo = strInfo & objChild.Name & vbTab
objUser = objChild.Name
Call UserInfo(objUser)
strInfo = strInfo & objUser & vbCRLF
Next
Wscript.Echo strInfo
Sub UserInfo(objChild)
Dim objUser
Set objUser = GetObject("LDAP://" & objChild & ",CN=Users," & _
objDSE.Get("defaultNamingContext"))
objChild = objUser.Profile
Set objUser = Nothing
End Sub
'-------------
'End of Script
'-------------
I'm receiving an error that states the Active Directory property cannot be found in the cache, which pertains to line 30 (objChild = objUser.Profile)
If my implementation is wrong, the error is definitely right. But I've compared my implementation to another script performing a similar task, and everything adds up. The only properties I can access from objUser are Name and Description.
Ultimately, my goal is to enumerate all users from a particular container, and show the Profile property for each user. Doesn't seem like a difficult task! :)
Any help concerning this would be much appreciated! Thanks.
_M