Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to extract Group name from windows active directory?

Status
Not open for further replies.

alisaif

ISP
Apr 6, 2013
418
AE
Hi,

Please refer to the subject, How can I get the same from Windows Server 2012 active Directory.

I am using Mr.Mike Gagnon's code which is giving me the details of the users.

Code:
strDomain = "STG"
Clear
On Error 
Public PrimDomainContr
Create Cursor names (username c(30),;
                     fullname c(80),;
                  description c(80),;
                        Class c(50),;
                       accdisable l,;
                        acclocked l,;
                      profile c(30),;
                  loginscript c(50),;
                      Homedir c(30))

PrimDomainContr = Getobject("WinNT://" + strDomain)
For Each User In PrimDomainContr
    If User.Class = 'User'
        Insert Into names (username,fullname,description,Class,accdisable,acclocked,profile,;
        loginscript,Homedir) Values (User.Name,user.fullname,User.description,User.Class,User.AccountDisabled,;
        User.IsAccountLocked,User.Profile,User.loginscript,User.Homedirectory)
    Endif
Next
Browse Norm

In addition to that kindly let me know how to include group name in the above mentioned code?

Thanks

Saif
 
A quick google suggests that something from here will take you in the right direction:

Code:
Set usr = GetObject("WinNT://Fabrikam/jsmith,user") 
grpPrimaryID = usr.Get("PrimaryGroupID")
This is VB, for VFP in your above example, the syntax would be more like:
Code:
replace names.Group with User.Get("PrimaryGroupID")




Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are not good for you.
 
Mike, this would be really good if it could include a column for how many files each has open.
Can that be done ?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top