Solved

Getting a group's members on Active Directory using NetGroupGetUsers

Posted on 2004-09-13
3
750 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now