View modify LDAP query policy (VBScript)
This code can be found in
Chapter 4 of Active Directory Cookbook, 2nd edition
Purchase XP Cookbook or Networking Recipes for only $25 plus shipping! While supplies last.
Find out how to download all of the VBScript code from this site.
' This VBScript code modifies a setting of the default query policy for a forest
' ---------------------------------------------------------------
' From the book "Active Directory Cookbook" by Robbie Allen
' Publisher: O'Reilly and Associates
' ISBN: 0-596-00466-4
' Book web site: http://rallenhome.com/books/adcookbook/code.html
' ---------------------------------------------------------------
' ------ SCRIPT CONFIGURATION ------
pol_attr = "MaxPageSize" ' Set to the name of the setting you want to modify
new_value = 1000 ' Set to the value of the setting you want modify
' ------ END CONFIGURATION ---------
Const ADS_PROPERTY_APPEND = 3
Const ADS_PROPERTY_DELETE = 4
set rootDSE = GetObject("LDAP://RootDSE")
set ldapPol = GetObject("LDAP://cn=Default Query Policy,cn=Query-Policies," & _
"cn=Directory Service,cn=Windows NT,cn=Services," & _
rootDSE.Get("configurationNamingContext") )
set regex = new regexp
regex.IgnoreCase = true
regex.Pattern = pol_attr & "="
for Each prop In ldapPol.GetEx("ldapAdminLimits")
if regex.Test(prop) then
if prop = pol_attr & "=" & new_value then
WScript.Echo pol_attr & " already equal to " & new_value
else
ldapPol.PutEx ADS_PROPERTY_APPEND, "lDAPAdminLimits", _
Array( pol_attr & "=" & new_value )
ldapPol.SetInfo
ldapPol.PutEx ADS_PROPERTY_DELETE, "lDAPAdminLimits", Array(prop)
ldapPol.SetInfo
WScript.Echo "Set " & pol_attr & " to " & new_value
end if
Exit For
end if
next
|
This code has been viewed 3463 times.
|
New from the creators of TechTasks.com:
StatSheet.com
|