9/20/2007

Print out security group

Print out security group

#-----------------------------
# Save the following as sec_grp.vb
#-----------------------------
For Each strGroup In objUser.MemberOf
strGroupPath = "LDAP://" & strGroup
Set objGroup = GetObject(strGroupPath)
strGroupName = objGroup.CN

Select Case strGroupName
Case "Group A"
Case "Group B"
End Select
Next

9/12/2007

Computer(s) that user can log on to the windows domain

Computer(s) that user can log on to the windows domain

#--------------------------------------
#Save the following as user_pc.vb
#--------------------------------------
'This script returns only a list of the computer objects
'found in the Servers OU. How do we know that it returns
'only computer objects? Note the Filter, which specifies
'just one item: Computer.
'Only work for win2k3 and XP because it use ADAM OU

'Set colItems = GetObject ("LDAP://ou=Servers, dc=fabrikam, dc=com")
'colItems.Filter = Array("Computer")

'For Each objItem in colItems
' Wscript.Echo objItem.CN
'Next

'-------------------------------------------------------
Const ForAppending = 8

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
("c:\temp\computers.txt", ForAppending, True)

' This one work for win2k enumerate All the Objects in an Active Directory OU
Set colItems = GetObject _
("LDAP://OU=Developers,dc=artificial-life,dc=com")

For Each objItem in colItems
If objItem.class="user" And objItem.AccountDisabled = FALSE Then
Set objUser = GetObject("LDAP://cn=" & objItem.CN &",OU=Developers,dc=artificial-life,dc=com")
'Wscript.Echo objItem.CN
'Wscript.Echo "Log on computer(s): " & objUser.userWorkstations
objTextFile.WriteLine(objItem.CN & vbTab & objUser.userWorkstations)
End If
Next

9/11/2007

Determine the ADsPath for the Logged-On User

Determine the ADsPath for the Logged-On User

#-----------------------
#Save the following as adspath.vb
#-----------------------

On Error Resume Next

Set objSysInfo = CreateObject("ADSystemInfo")

strUser = objSysInfo.UserName
Set objUser = GetObject("LDAP://" & strUser)

Wscript.Echo objUser.AdsPath

#----------------------
#Done
#----------------------
this is an incredibly useful object, one that can return all sorts of information about the logged-on user and the local computer.

The one drawback to this object is the fact that it can only be created locally: you can’t create an instance of ADSystemInfo on a remote computer and then get information about the user logged on to that machine.