----- Original Message -----
Sent: Monday, November 03, 2003 8:09
PM
Subject: [ActiveDir] Another scripting
bug...
I asked this
question of Siegfried some time ago, and he said it was a bug. I believe him.
Does anything know a way around it, oh script guru's? Or could one of you
submit a bug report to someone that would care? :-)
I have a number of
accounts whose Exchange alias has an ampersand in it. The historical reason
for that is MS' fault, but that's neither here nor there. They just are. I use
the routine below to get the size of the mailboxes. However, for those
accounts whose alias has the ampersand in it, the open fails with the
error:
| Object or data matching the name,
range, or selection criteria was not found within the scope of this
operation. |
Any ideas for
working around this problem? Obviously there is SOME way, because ESM doesn't
have this issue (obviously, I'd prefer a vbscript solution -- I'm not really a
programmer these days).
Thanks,
M
Function
GetMailboxSize (strMailBoxName, strDomainName)
Dim
sUserName ' As String
Dim mailboxSZ ' As
Double
Dim sURL ' As String
Dim
sSQL ' As String
Dim Rs ' As New
ADODB.Recordset
Dim Rec ' As New
ADODB.Record
On Error Resume
Next
set Rs = Wscript.CreateObject ("ADODB.Recordset")
set
Rec = Wscript.CreateObject ("ADODB.Record")
mailboxSZ = 0
sUsername = strMailBoxName
Rec.Open sURL
If Err.Number <> 0
Then
strErr = "Could not open: "
& sURL & " (" & err.Description &
")"
GetMailboxSize =
-1
Exit
Function
End If
sSQL = "Select"
sSQL = sSQL &
" ""http://schemas.microsoft.com"
&
_
"/exchange/foldersize"" "
sSQL = sSQL & ",
""DAV:displayname"" "
sSQL = sSQL & " from scope
('deep traversal of " & Chr(34)
sSQL = sSQL &
sURL & Chr(34) & "')"
sSQL = sSQL & "Where
""DAV:isfolder""=true"
Rs.Open
sSQL, Rec.ActiveConnection
If Not
Rs.EOF Then
Rs.MoveFirst
End If
While Not
Rs.EOF
mailboxSZ = mailboxSZ +
_
Rs.Fields("http://schemas.microsoft.com/exchange/foldersize").Value
Rs.MoveNext
Wend
GetMailboxSize =
mailboxSZ
Rs.Close
Rec.Close
set Rs = Nothing
set Rec = Nothing
End
Function