From: tiv on
Hi All....

I'm trying to connect to an ldap provider and pull user photos and
save them to file. The vbscript i'm using runs fine (kinda sorta).
It does connect and pull the photos out and saves them to file, but it
only pulls the first 500 users and then I get this error "Provider:
The size limit for this request was exceeded." I've tried playing
around with the provider and page size to no avail. Thanks in advance
for any suggestions or advice!

###################################################################
' Set path to save picture
slocal="C:\Pics-AD\"

' Ask user for specific username if not exporting in bulk
strUserID = InputBox("Please enter user ID:Leave Blank to export all
users",,"")

If strUserID = "" Then
strUserID = "*"
End if

' Instantiate the connection and log in to OpenLDAP
Set oConn = CreateObject("ADODB.Connection")
oConn.Provider = "ADsDSOObject"
oConn.Open "LDAP Provider"

' Execute the search...
Set com = CreateObject("ADODB.Command")
Set com.ActiveConnection = oConn
com.CommandText = "<LDAP://myserver:389/dc=ybusa,dc=com>;
(&(jpegPhoto=*)(objectClass=person)(cn=" & strUserID &
"));cn,jpegPhoto;subtree"
com.Properties("Page Size") = 100
com.Properties("Cache Results") = False

Set oRS = com.Execute
oRS.Sort = cn

' Create an array of returned values
vCount = 0
Do Until oRS.EOF = True'vCount = 5 or

For Each vValue in oRS.Fields("cn").value
For Each vValue2 in oRS.Fields("jpegPhoto").value

WScript.Echo vValue
WScript.Echo vValue2

set ostream = createobject("adodb.stream")
with ostream
.type=1 'binary
.mode=3 'read-write
'.open
'.write vValue2
'.savetofile slocal & vValue & ".jpg",2 'save-create-overwrite
'.close
end with
Next
Next

vCount = vCount + 1
oRS.MoveNext
Loop