[gptalk] Re: How to get the list of users in a group.

  • From: "Aaron Rabinowitz" <rabino67@xxxxxxxxx>
  • To: gptalk@xxxxxxxxxxxxx
  • Date: Fri, 14 Nov 2008 09:16:30 -0500

I used the following script that I got off a forum that worked ggreat,
you only ahve to change the second line. and it will dispaly all the
suers in excel



Dim objGroup, objExcel, iRow, strUser
Set objGroup = GetObject("LDAP://CN=xxxxxxxx,ou=yyyyyy,dc=domain,dc=com")

Set objExcel = CreateObject("Excel.Application")
With objExcel
  .SheetsInNewWorkbook = 1
  .Workbooks.Add
  .Visible = True
  .Worksheets.Item(1).Name = mid(objGroup.Name,
instr(1,objGroup.Name,"=") + 1 ) 'set Worksheet name to that of the DL
  irow=1

 For Each strUser in objGroup.Member
    Set objUser =  GetObject("LDAP://" & strUser)
    .Cells(iRow,1) = objUser.CN
    irow=irow + 1
 Next
 .Columns(1).entirecolumn.autofit
End With

Set objExcel = Nothing
Set objGroup = Nothing




On Fri, Nov 14, 2008 at 9:10 AM, rpo <rpo8373@xxxxxxxxx> wrote:
> hi ananth,
>
> this isn't really gpo related. and by not really, i mean...not at all.
>
> nevertheless, replace the following line:
>
> GetObject("LDAP://CN=pm_anim_artists,DC=Tai3D,DC=com")
>
> with:
>
> GetObject("LDAP://CN=pm_anim_artists,cn=Users,DC=Tai3D,DC=com")
>
> should do the trick i reckon. good luck.
>
> daniel.
>
>
> On 14/11/2008, Ananth Rajagopal <ananth.rg@xxxxxxxxx> wrote:
>> Hi All,
>>
>> We are having a 300 user AD. According to project needs we have created
>> several groups. Now we wold like to get the list of users in these groups.
>>
>> We got a script from MS Scriptcenter, but it is returning an error....
>> please advice....
>>
>> I've attached an image of our users and groups.
>>
>> Dim arrNames()
>> intSize = 0
>>
>> Set objGroup =
>> GetObject("LDAP://CN=pm_anim_artists,DC=Tai3D,DC=com")
>>
>> For Each strUser in objGroup.Member
>>     Set objUser =  GetObject("LDAP://" & strUser)
>>     ReDim Preserve arrNames(intSize)
>>     arrNames(intSize) = objUser.CN
>>     intSize = intSize + 1
>> Next
>>
>> For i = (UBound(arrNames) - 1) to 0 Step -1
>>     For j= 0 to i
>>         If UCase(arrNames(j)) > UCase(arrNames(j+1)) Then
>>             strHolder = arrNames(j+1)
>>             arrNames(j+1) = arrNames(j)
>>             arrNames(j) = strHolder
>>         End If
>>     Next
>> Next
>>
>> For Each strName in arrNames
>>     Wscript.Echo strName
>> Next
>>
>> We are "There is no such object on the server" message. Selected users are
>> members of ordinary groups. So we are wondering where we went wrong.
>>
>> Thanks and regards
>> Ananth.
>>
>>
> ***********************
> You can unsubscribe from gptalk by sending email to 
> gptalk-request@xxxxxxxxxxxxx with 'unsubscribe' in the Subject field OR by 
> logging into the freelists.org Web interface. Archives for the list are 
> available at http://www.freelists.org/archives/gptalk/
> ************************
>
***********************
You can unsubscribe from gptalk by sending email to 
gptalk-request@xxxxxxxxxxxxx with 'unsubscribe' in the Subject field OR by 
logging into the freelists.org Web interface. Archives for the list are 
available at http://www.freelists.org/archives/gptalk/
************************

Other related posts: