• Embed Doc
  • Readcast
  • Collections
  • CommentGo Back
Download
 
'***************************************************'This script will pull all users that have Dial-in'access from Active Directory and the OU the account'is in and writes the values out to a CSV file'***************************************************Option ExplicitOn Error Resume NextConst ADS_SCOPE_SUBTREE = 2Dim objConnection, objCommand, objRootDSEDim objRecordSet, ouDim namingContext, fso, outFileSet objConnection = CreateObject("ADODB.Connection")Set objCommand = CreateObject("ADODB.Command")objConnection.Provider = "ADsDSOObject"objConnection.Open "Active Directory Provider"Set objCommand.ActiveConnection = objConnectionset objRootDSE = getobject("LDAP://RootDSE")namingContext = objRootDSE.Get("defaultNamingContext")set objRootDSE = nothingSet fso = CreateObject("Scripting.FileSystemObject")Set outFile = fso.CreateTextFile("RRAS_VPN_Users.txt", True)objCommand.Properties("Page Size") = 1000objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREEobjCommand.CommandText = _"SELECT Name FROM 'LDAP://" & namingContext & _"' WHERE objectCategory='user' " & _"AND msNPAllowDialin = TRUE"Set objRecordSet = objCommand.ExecuteobjRecordSet.MoveFirstDo Until objRecordSet.EOF' Call function to find OU from computer nameou = getOUByUserName(objRecordSet.Fields("Name").Value)outFile.WriteLine(objRecordSet.Fields("Name").Value & _",'" & ou & "'")objRecordSet.MoveNextLoopoutFile.CloseWScript.Echo "Complete"WScript.Quitfunction getOUByUserName(byval UserName)' *** Function to find ou/container of user object ***DIM namingContext, ldapFilter, ouDIM cn, cmd, rs
of 00

Leave a Comment

You must be to leave a comment.
Submit
Characters: ...
You must be to leave a comment.
Submit
Characters: ...