Re: Not enough storage is available to process this command
- From: "Richard Mueller [MVP]" <rlmueller-nospam@xxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 13 Aug 2008 19:28:27 -0500
You don't indicate which is line 125. However, it might help to specify some
properties of the ADO Command object. I would try:
objCommand.Properties("Page Size") = 100
objoCommand.Properties("Timeout") = 30
objCommand.Properties("Cache Results") = False
Insert these before you run the Execute method. Also, the member attribute
is multi-valued and ADO will only return 1500 values (1000 in Windows 2000
AD). This will not raise an error, but if any groups have more members you
will need to use Range Limits to overcome the limiation.
Another issue is that you bind to each group object. This negates the
advantages of ADO and slows the program considerably. The program is a bit
complex to analyze in detail, but it looks like you use the object reference
objGroup to retrieve the values of the attributes sAMAccountName, groupType,
description, and managedBy. All of these attributes could be added to the
comma delimited list of attribute values to retrieve, so there would be no
need to bind to each group object. For example:
objCommand.CommandText = _
"<" & strADPath & ">" & ";(&(objectCategory=group)(mail=*))" _
&
";distinguishedName,member,sAMAccountName,groupType,description,managedBy;subtree"
I used (objectCategory=group) because objectCategory is indexed (objectClass
is not) so the filter will be more efficient. The only caution is the
description attribute is multi-valued (although there is never more than one
value) so that ADO returns an array (similar to member) you need to loop
through (and the array is Null if there is no value).
I see you also bind to the manager object if managedBy has a value. It's
probably not worth it, but if a lot of groups have managers (especially the
same manager) the program would be more efficient if you kept track of
managers in a dictionary object, again to reduce the number of AD objects
that are bound. By far the biggest impact on performance is the number of AD
objects that a program binds to over the network. That's why programs that
use ADO are so much faster - all the work is done on the server and the
client gets one recordset.
--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--
"Chris" <Chris@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:0C32033D-54D2-4BD1-9A91-AE1D93D9DB04@xxxxxxxxxxxxxxxx
Here is the code. I got it from others and made change to the output
format.
It works but stopped with that error at certain point. The exact error is
in my original posting. Thanks.
'==================================================================================================
'
' VBScript Source File
'
' NAME: ListDistGroups.VBS
' AUTHOR: Bharat Suneja ,
' DATE : 8/02/2004
' MODIFIED FOR GENERAL USE - 2/13/2006
' MODIFIED FOR FILE OUTPUT - 3/19/2006
'==================================================================================================
' COMMENT:
'
'
' Lists all groups in a domain
' Shows whether group is Dist. Group or Security Group
' Outputs members of group
'
'==================================================================================================
' updated 3/19/2007: Added option to suppress console output, provide a
file path for file output, and /HELP option
'==================================================================================================
'BANNER INFO
Wscript.Echo "This script lists all groups in the domain"
Wscript.Echo "Format: Group Name, Group Type, Members"
Wscript.Echo "Report Generated at : " & Now & VbCrLf
strOutput = strOutput & VbCrLf & "Report Generated at : " & Now & VbCrLf
'Pickup Named Arguments
Set colNamedArguments = WScript.Arguments.Named
strOutputFile = colNamedArguments.Item("f")
strNoConOutput = colNamedArguments.Item("s")
strHelp = colNamedArguments.Item("help")
'Detect help and write help text to console
WriteHelp
'Get RootDSE
Set objRootDSE = GetObject("LDAP://rootDSE")
strDomain = objRootDSE.Get("defaultNamingContext")
strADPath = "LDAP://" & strDomain
Set objDomain = GetObject(strADPath)
wscript.echo "Domain: " & objDomain.distinguishedName
'Setup ADODB connection
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=ADsDSOObject;"
Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection
'Execute search command to look for user
objCommand.CommandText = _
"<" & strADPath & ">" & ";(&(objectClass=group)(mail=*))" &
";distinguishedName,member;subtree"
Set objRecordSet = objCommand.Execute
Wscript.Echo "DISTRIBUTION GROUPS FOUND: " & objRecordSet.RecordCount &
VbCrlf
Wscript.Echo
"--------------------------------------------------------------------------------------------"
& VbCrlf & VbCrlf
I = 0
While Not objRecordSet.EOF 'Iterate through the search results
I = I + 1
strGroupDN = objRecordSet.Fields("distinguishedName")
set objGroup= GetObject("LDAP://"& strGroupDN & "")
strFirstLine = ""
strFirstLine = strFirstLIne & I & "#" & objGroup.sAMAccountName
& " # "
If objGroup.GroupType = 2 Then
'strFirstLine = strFirstLIne & "Security Group" & "#"
'Else
strFirstLine = strFirstLIne & "Distribution Group" & "#"
End If
strDescription = objGroup.description
strFirstLine = strFirstLine & strDescription & "#"
'Get manager's name
If objGroup.managedBy = "" Then
'Wscript.Echo "This group does not have a Manager."
strFirstLine = strFirstLine & "No Manager" & "#" & VbCrlf
Else
strManagerDN = objGroup.managedBy
set objManager = GetObject("LDAP://"& strManagerDN & "")
strManagerName = objManager.displayName
strFirstLine = strFirstLine & strManagerName & "#" &
VbCrlf
End If
'strWhenCreated = objRecordSet.Fields("whenCreated")
_
'Shows when the account was created, disable if not
required
'Group operation: Gets group memberships, checks if
Distribution Group, deletes if Distribution Group
If IsNull (objRecordSet.Fields("member")) Then 'Checks
if the user has already been removed from all groups
strFirstLine = strFirstLIne & "---NONE---"
Else
'strFirstLine = strFirstLIne & VbCrlf & "Members: "
For each varUser in objRecordSet.Fields("member").Value
Set objUser = GetObject("LDAP://" & varUser)
'Wscript.Echo "Group Type= " & objUser.Grouptype
strFirstLine = strFirstLIne &
objUser.displayName
& VbCrlf
Next
End If
'strFirstLine = strFirstLIne & "#"
'Wscript.Echo "-----------------------" & VbCrlf
Wscript.Echo strFirstLine
strOutput = strOutput & VbCrLf & strFirstLine
objRecordSet.MoveNext
Wend
WriteCon
WriteFile
'=======================================================
' FUNCTIONS
'=======================================================
Sub WriteFile
'Open new text file, write info, close file
If IsEmpty(strOutputFile) Then
WScript.Echo "No file output"
Else
Set objFSO =
CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile(strOutputFile)
'Write Stuff
objFile.WriteLine strOutput
'Close text file
objFile.Close
End If
End Sub
'---------------------------------
'SUB Write Console
Sub WriteCon
If Not colNamedArguments.Exists("s") Then
WScript.echo strOutput
Else
WScript.Echo "No console output"
End If
End Sub
'------------------
Sub WriteHelp
If colNamedArguments.Exists("help") Then
strHelpText = "USAGE: ListDistGroups_audit-dev.vbs" & VbCrLf &
"OPTIONAL Arguments: /s:y - no console output" & VbCrLf & _
"/f:Output_File_Name.txt - writes output to txt file in the
argument" & VbCrLf & "/help - help text" & VbCrLf & _
" ListDistGroups_audit-dev.vbs /f:c:\DistributionGroups.txt
/s:y -
produces " & VbCrLf & "file DistributionGroups.txt " & " and no console
output"
WScript.Echo strHelpText
WScript.Quit
End If
End Sub
"krazymike" wrote:
Yeah, I'd like to see the code, especially the line it's failing on.
.
- References:
- Prev by Date: Windows XP Explorer display
- Next by Date: Re: I 'm looking for a compiler ...
- Previous by thread: Re: Not enough storage is available to process this command
- Next by thread: I 'm looking for a compiler ...
- Index(es):
Relevant Pages
|