WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

wNT
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Get a Users Primary Group

 Keywords: Get Users Primary Group 

Question:

I'm trying to get the primary group of the current user, with wntUserGetDat I get the ID of the group. How can I get the name of this ID?
AddExtender("WWWNT34i.DLL")

; current user 
vUser=wntGetUser(@default)
Message("Current user =",vUser)

vDomain=StrUpper(Environment("USERDOMAIN"))
; PDC 
vPDC=wntGetDc( "",vDomain, 1)
Message("PDC =",vPDC)
;DC 
vDC=wntGetDc( "",vDomain, 0)
Message("DC =",vDC)

; Primary group 
vPrimaryGrp=WntUserGetDat(vPDC,vUser,"primary_group_id")
Message("Primary Group =", vPrimaryGrp)

Answer:

Continue on with the following as an extension to your existing code...
vDomainSID = wntLsaPolGet(vPDC,"PrimaryDomain",2)
vPrimaryGrpName = wntAcctInfo(vPDC,StrCat(vDomainSID,'-',vPrimaryGrp),2,0)
Message("Primary Group Name =",vPrimaryGrpName)

Article ID:   W15195
File Created: 2002:09:05:13:50:30
Last Updated: 2002:09:05:13:50:30