Solved

Getting a group's members on Active Directory using NetGroupGetUsers

Posted on 2004-09-13
3
761 Views
Last Modified: 2008-01-09
Hey guys.

I have a program that extracts the members of a group using the NetGroupGetUsers function. It used to work fine until we migrated to Active Directory. The user that runs the function is set as domain administrator so I don't believe that there is a security issue here. The error code that is returned by the function is 2220 which means the the group isnt't found.

I have checked the name with the LAN and there is no spelling errors.

Any ideas?

Thanks.

Luc.
0
Comment
Question by:LucDesaulniers
  • 2
3 Comments
 
LVL 26

Expert Comment

by:EDDYKT
ID: 12043995
Or just use this

'member in group
Dim grp As IADsGroup
Dim memberList As IADsMembers
Dim member As IADs

Set grp = GetObject("WinNT://yourdomainname/Administrators")
Set memberList = grp.members
For Each member In memberList
  Debug.Print member.Name & "(" & member.Class & ")"
Next
0
 

Author Comment

by:LucDesaulniers
ID: 12044093
What do I need to reference to make this work? I get a "user-defined type not defined" error on the IADsGroup type.

Thanks.
0
 
LVL 26

Accepted Solution

by:
EDDYKT earned 500 total points
ID: 12044469
add Active DS Type library

activeds.tlb


if you don't have you can download from here

http://www.microsoft.com/ntserver/nts/downloads/other/ADSI25/default.asp

Or

just change to object

ie

Dim grp As object
Dim memberList As object
Dim member As object
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question