Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADSI - Enumerating Resources

Status
Not open for further replies.

Beard36

Programmer
Sep 4, 2003
69
GB
I'm not 100% that I'm posting this question in the correct forum, but I'm writing the script in vbs, so it seemed reasonable enough..

Anyway, I've a got a simple script to list the network resources on the server. It starts off fine, but it part way through it will display the .Name property but fail when it tries to read .User with "Active Directory: The Active Directory property cannot be found in the cache."

Is there something I'm missing here? I've got no idea what the problem is, if someone could point me in the right direction it would be much appreciated.

Thanks in advance,
Dan.


Set adsComputer = GetObject("WinNT://domain/server/LanManServer")

For Each adsResource In adsComputer.Resources
WScript.Echo adsResource.Name
WScript.Echo adsResource.User
WScript.Echo adsResource.Path
Next
 
You are returning a collection of 'Resources'

Are you sure each resource has to have a .User property?
Its my guess the resource you are currently working on doesnt have one and therefore a call to retrieve its User property will fail.

 
Hello Beard36,

Are you sure of the .Resources?! If you want the users' info, try do it this way. See it and you know it.
Code:
set fsvc = GetObject("WinNT://domain/server/LanmanServer")
for each oSession in fsvc.Sessions
    with oSession
        wscript.echo _
            "Computer: " & .Computer & vbcrlf & _
            "Connected Time: " & .ConnectTime & vbcrlf & _
            "User\Computer: " & .Name & vbcrlf & _
            "Idle Time: " & .IdleTime & vbcrlf & _
            "Username: " & .User
    end with
next
set fsvc = nothing
regards - tsuji
 
Well, I'm probably doing this in a crazy round about way (but when I've started something and it doesn't work it drives me mad until I understand why, even if it turns out now to be the best solution to the problem) -

What I'd like to do is examine a share on the server and determine how many users are connected to it, and who those users are / what computer they're on*. Now that I've started looking at this .Resource collection I also think that sometime soon I'll be using it to identify which users are accessing any given file (unless, again, it turns out there is a better way to do this).

Another question: my understanding of the Resources collection is a bit limited. I've been reading a bit about it, but I'm still confused - if there is a resource that DOESN'T have a user or a path, what is it for?

Once again, thanks to anyone who can shed some light on my problem / misunderstanding(s). :)

Beard36.

* (The idea is that I use WMI to identify the path of the share in question, then run through all of the resources to see who has a file open in this path (or in one of its subfolders)).
 
unfortunately i am unfamiliar with the LanManServer object, with that in mind i would welcome a post of where we could obtain a full object model for it??

thanks
richard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top