Outstanding. Thank you.
-----Original Message-----
From: Coleman, Hunter [mailto:[EMAIL PROTECTED]
Sent: Thursday, June 12, 2003 12:47 PM
To: '[EMAIL PROTECTED]'
Subject: RE: [ActiveDir] Looking up all email addresses1,000 records sounds right for the default ADODB limit. However, you can specify a Page Size on the ADODB command which will allow you to return more than 1,000 records.set adoRecordset = CreateObject("ADODB.Recordset")set Com = CreateObject("ADODB.Command")
set Com.ActiveConnection = adoConnectionCom.Properties("Page Size") = 100
Com.Properties("Timeout") = 30 'seconds
Com.Properties("Searchscope") = 2 'ADS_Scope_subtreestrQuery = <your query here>Com.CommandText = strQuerySet adoRecordset = Com.Execute
From: Michael B. Smith [mailto:[EMAIL PROTECTED]
Sent: Thursday, June 12, 2003 9:51 AM
To: [EMAIL PROTECTED]Dude, you rock. It took me a little while to get the LDAP search string to be exactly what I wanted (a plus for iteration!), but after that it worked great!Thanks so much for the pointer.I do have one question - I was somehow under the impression that LDAP queries via ADODB were limited to returning about 1,000 records. Am I wrong?1 -- yeah, i had a recursive subroutine that actually was calling another subroutine for each OU of interest. A PITA.2 -- even on my test domain it was slow. On my test domain, the LDAP search seems to be about 10 times faster. On a larger domain, I'm sure it would ramp up quickly.Thanks again,Michael-----Original Message-----
From: Joe [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 11, 2003 10:12 PM
To: [EMAIL PROTECTED]
Subject: RE: [ActiveDir] Looking up all email addressesI would just say that iteration through the users in this way has two failings1. If you have users in some other container or OU, you ain't seeing them here.2. Iteration is kind of slow compared to doing an LDAP search and displaying the specific fields you asked to have returned, even if you use vbscript and ado. Basically as your directory grew this script would really slow down.If I understand what you are trying to get here (white space management is throwing me), to display the user's that have mailboxes userprincipalname, samaccountname, homemdb and proxyaddresses info I think I would simply do something like:adfind -default -f "&(objectcategory=person)(samnaccountname=*)(homemdb=*)" userprincipalname samaccountname homemdb proxyadddressesI don't have the exchange attributes handy to see if homemdb is indexed, if it isn't I would use some other exchange attribute that is indexed instead. The beauty of that query is that it will do the entire domain, if you just wanted the users container you could doadfind -b cn=users,dc=domain,dc=com -f "&(objectcategory=person)(samnaccountname=*)(homemdb=*)" userprincipalname samaccountname homemdb proxyadddressesor if you wanted the whole forest you could doadfind -gc -b "" -f "&(objectcategory=person)(samnaccountname=*)(homemdb=*)" userprincipalname samaccountname homemdb proxyadddressesIt will have a count of how many matching objects at the very end of the run.Sorry I didn't post script code, shouldn't be hard to put it together though if you understand the concepts I am trying to propose. Should be a ton of stuff you can leverage at the script center or in microsoft.public.adsi.general that you can convert.joe-------Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Michael B. Smith
Sent: Wednesday, June 11, 2003 5:12 PM
To: [EMAIL PROTECTED]
Subject: RE: [ActiveDir] Looking up all email addressesThanks. I just figured it out a couple of minutes ago. This works:Set objContainer = GetObject("LDAP://" + DomainName)objContainer.Filter = Array("User")
i = 0For Each objUser In objContainer
name = objUser.name
wscript.echo "name: " & name & " upn: " & objUser.UserPrincipalName & " sam: " & objUser.samAccountName
name = Right(name, Len(name) - 3)
Set objMailbox = objUser
If objMailbox.HomeMDB = "" Then
'Wscript.echo name + " (no mailbox)"
Else
'Wscript.echo name + " (has mailbox)"
'Wscript.echo objMailbox.HomeMDB
' email addresses
Set objR = objUser
AddressList = objR.ProxyAddresses
for each Address in AddressList
if lcase (left (Address, 5)) = "smtp:" Then
Wscript.echo Address
end if
next
End If
i = i + 1
Next'Wscript.echo "Number of users found in " & DomainName & ": " & i-----Original Message-----
From: Roger Seielstad [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 11, 2003 5:03 PM
To: '[EMAIL PROTECTED]'
Subject: RE: [ActiveDir] Looking up all email addressesI wrote the code below a while ago to do something similar, and should work for you.Its written for an Exchange 5.5 server, but the logic is pretty similar for AD/E2k as well.--------------------------------------------------------------
Roger D. Seielstad - MTS MCSE MS-MVP
Sr. Systems Administrator
Inovis Inc.-----Original Message-----
From: Michael B. Smith [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 11, 2003 3:51 PM
To: [EMAIL PROTECTED]
Subject: [ActiveDir] Looking up all email addressesI need a piece of code that, given a user object, returns me an object or collection to all of the email addresses for that user. I can't find the object.Help!Set objContainer = GetObject("LDAP://CN=Users," + DomainName)objContainer.Filter = Array("User")
i = 0For Each objUser In objContainer
name = objUser.name
name = Right(name, Len(name) - 3)
Set objMailbox = objUser
<<---->>> code goes here!!!If objMailbox.HomeMDB = "" Then
Wscript.echo name + " (no mailbox)"
Else
Wscript.echo name + " (has mailbox)"
End If
i = i + 1
Next
Wscript.echo "Number of users found in the DS (in the default container): " & iThanks
