Thanks a lot, Tony

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Tony Murray
Sent: Monday, March 18, 2002 10:09 PM
To: [EMAIL PROTECTED]
Subject: Re: [ActiveDir] How do I count?


The following script should do the trick (works for me).  I cobbled it
together from two different scripts available at www.kouti.com.  Basically,
it searches all containers for user objects and writes their Distinguished
Name and Description attributes to 2 separate columns in an Excel
spreadsheet.

Tony

*****************

'       Copyright (C) 2002 by Addison-Wesley
'       Script by Sakari Kouti (see http://www.kouti.com)
' You have a royalty-free right to use, modify, reproduce and distribute
' this script (and/or any modified version) in any way you find useful,
' provided that you agree that Addison-Wesley or Sakari Kouti has no
' warranty, obligations or liability for the script. If you modify
' the script, you must retain this copyright notice.
' -------------------------------------------------------------------------
Option Explicit
Dim objDSE, strDefaultDN, strDN, objExcel, objContainer, objChild

'strDN = InputBox("Enter the distinguished name of a container")
Set objDSE = GetObject("LDAP://rootDSE";)
strDefaultDN = objDSE.Get("defaultNamingContext")

strDN = InputBox("Enter the distinguished name of a container" & _
        vbCrLf & "(e.g. " & strDefaultDN & ")", , strDefaultDN)

Set objExcel = WScript.CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.Workbooks.Add

objExcel.ActiveSheet.Name = "Users of " & Left(strDN,19) & "..."
objExcel.ActiveSheet.Range("A1").Activate
objExcel.ActiveCell.Value = "Name"                                              'col 
header 1
objExcel.ActiveCell.Offset(0,1).Value = "Description"   'col header 2
objExcel.ActiveCell.Offset(1,0).Activate                                'move 1 down

Set objContainer = GetObject("LDAP://"; & strDN)

Call ListUsers(objContainer)

Sub ListUsers(objADObject)
        Dim objChild
        For Each objChild in objADObject
                Select Case objChild.Class
                        Case "user"
                                objExcel.ActiveCell.Value = objChild.distinguishedName
                                objExcel.ActiveCell.Offset(0,1).Value = 
objChild.Description
                                objExcel.ActiveCell.Offset(1,0).Activate               
         'move 1 down
                        Case "organizationalUnit" , "container"
                                Call ListUsers(objChild)
                End select
        Next
End Sub
******************
---------- Original Message ----------------------------------
From: "Nilesh Gajjar" <[EMAIL PROTECTED]>
Reply-To: [EMAIL PROTECTED]
Date: Mon, 18 Mar 2002 16:34:02 +0530

Hi All,

Any idea, How to count the no of user objects in AD?

Thanks
-Nilesh
List info   : http://www.activedir.org/mail_list.htm
List FAQ    : http://www.activedir.org/list_faq.htm
List archive: http://www.mail-archive.com/activedir%40mail.activedir.org/

List info   : http://www.activedir.org/mail_list.htm
List FAQ    : http://www.activedir.org/list_faq.htm
List archive: http://www.mail-archive.com/activedir%40mail.activedir.org/

List info   : http://www.activedir.org/mail_list.htm
List FAQ    : http://www.activedir.org/list_faq.htm
List archive: http://www.mail-archive.com/activedir%40mail.activedir.org/

Reply via email to