How Can I Find All the Users with Remote Access Permissions?

19. März 2008 – 15:59

Jeder der ein Windows Server besitzt und VPN aktiv hat benötigt irgendwann eine Liste mit allen usern die “Allow Access” aktiviert haben.

Folgendes Script in eine .vbs Datei kopieren und mit cscript myscript.vbs > c:\logallowaccess.txt ausführen. Dann werden alle user die unter Dial-In, Allow Access aktiviert haben unter C:\logallowaccess.txt abgespeichert.

Bemerkung: Vorher muss im script die zeile “SELECT Name FROM ‘LDAP://dc=domaene,dc=com’ WHERE objectCategory=’user’ ” & _” editiert werden. (dc=domaene und dc=com)
On Error Resume Next

Const ADS_SCOPE_SUBTREE = 2

Set objConnection = CreateObject(“ADODB.Connection”)
Set objCommand = CreateObject(“ADODB.Command”)
objConnection.Provider = “ADsDSOObject”
objConnection.Open “Active Directory Provider”
Set objCommand.ActiveConnection = objConnection

objCommand.Properties(“Page Size”) = 1000
objCommand.Properties(“Searchscope”) = ADS_SCOPE_SUBTREE

objCommand.CommandText = _
“SELECT Name FROM ‘LDAP://dc=domaene,dc=com’ WHERE objectCategory=’user’ ” & _
“AND msNPAllowDialin = TRUE”
Set objRecordSet = objCommand.Execute

objRecordSet.MoveFirst
Do Until objRecordSet.EOF
Wscript.Echo objRecordSet.Fields(“Name”).Value
objRecordSet.MoveNext
Loop

Quelle:

http://www.microsoft.com/technet/scriptcenter/resources/qanda/aug05/hey0825.mspx

http://www.microsoft.com/technet/scriptcenter/resources/qanda/aug04/hey0817.mspx

Post a Comment