MSFN Forum: Help with VB Script - MSFN Forum

Jump to content



Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Help with VB Script Rate Topic: -----

#1 User is offline   bbbngowc 

  • Member
  • PipPip
  • Group: Members
  • Posts: 127
  • Joined: 09-August 06

Posted 20 October 2009 - 09:33 AM

Hi,

I'm trying to find all the users in AD that have Dial-in Access. However I need to use the "Control Access through Remote Access Policy" option as a lookup. So something like:

where obj=user and AND msNPAccessDialin = TRUE type thing. I have the follow code but it doesn't work for what I'm looking for. Can any help me with a mod please?

Const ADS_SCOPE_SUBTREE = 2

Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject")

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=domain,dc=com' WHERE objectCategory='user' " & _
		"AND msNPAccessDialin = TRUE"
Set objRecordSet = objCommand.Execute

Dim Ts

  Set Ts = Fso.CreateTextFile("Text_Report.txt")
  
   Ts.WriteLine Now
   
   objRecordSet.MoveFirst
   
	Do Until objRecordSet.EOF

	 Ts.WriteLine objRecordSet.Fields("Name").Value
   
	 Wscript.Echo objRecordSet.Fields("Name").Value
	 
	 objRecordSet.MoveNext
	Loop
  Ts.Close

This post has been edited by bbbngowc: 20 October 2009 - 09:37 AM



#2 User is offline   Yzöwl 

  • Wise Owl
  • Group: Super Moderator
  • Posts: 4,115
  • Joined: 13-October 04
  • OS:Windows 7 x64

Posted 20 October 2009 - 11:25 AM

If Remote Access Permission (Dial-in or VPN) Allow Access is selected then msNPAllowDialin is TRUE
If Remote Access Permission (Dial-in or VPN) Deny Access is selected then msNPAllowDialin is FALSE
If Remote Access Permission (Dial-in or VPN) Control Access through Remote Access Policy is selected then msNPAllowDialin has no value.

Therefore try changing the line to say:
WHERE objectCategory='user' " & _
		"AND msNPAllowDialin <> '*'"


#3 User is offline   bbbngowc 

  • Member
  • PipPip
  • Group: Members
  • Posts: 127
  • Joined: 09-August 06

Posted 24 October 2009 - 10:48 AM

View PostYzöwl, on Oct 20 2009, 01:25 PM, said:

If Remote Access Permission (Dial-in or VPN) Allow Access is selected then msNPAllowDialin is TRUE
If Remote Access Permission (Dial-in or VPN) Deny Access is selected then msNPAllowDialin is FALSE
If Remote Access Permission (Dial-in or VPN) Control Access through Remote Access Policy is selected then msNPAllowDialin has no value.

Therefore try changing the line to say:
WHERE objectCategory='user' " & _
		"AND msNPAllowDialin <> '*'"



Thanks. This worked.

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2011 msfn.org
Privacy Policy