1 minute read time

List Full Name of Members of a Specified Group

by in CyberRes


A quick and easy way to list all the members of a group object, including the user’s full name, and outputting the list to a csv file. This allows you to provide the list of real names to a manager/supervisor/<fill in the blank> and not expect them to recognize people by their username.

This vbscript requires nwdirq.dll and nwusrgrp.ocx from the active_ndap NDK (http://developer.novell.com/wiki/index.php/Activex_ndap) to be registered on the workstation.

This script will list all the users in a specified Group (the output is Full Name, OU the account is in, username) to a csv file.

set oFso = createobject("scripting.filesystemobject")
set oNWDirq = createobject("nwdirquerylib.nwdirquery.1")
set oNWUsrGrp = createobject("nwusrgrplib.nwusrgrpctrl.1")

cOutput1 = "c:\temp\GroupMembership-"
cOutput2 = ".csv"

sGroup = inputbox("What is the name of the group that you would like to list the members of?")

oNWUsrGrp.fullname = "NDS:\\---your tree name---\---your O name---\---OU that contains your groups---"

'*** Error trapping to catch cases where the group does not exist
'*** in the branch that the user selected
on error resume next
set oGroup = oNWUsrGrp.groups.item(oNWUsrGrp.fullname


  • the dll/ocx items in active_ldap do not work - cannot be registered. Tried Windows 7 and Windows XP .
  • I've found that parts of the Novell client that the dll and ocx rely on are no longer part of the client for windows 7, so I've had to convert my scripts to strait ldap queries. This is my latest version for listing the members of a group, which outputs to notepad.

    Set oConnection = CreateObject("ADODB.Connection")
    Set oCommand = CreateObject("ADODB.Command")
    set oShell = CreateObject("wscript.shell")
    oConnection.Provider = "ADsDSOObject"

    cNotepad = "c:\windows\notepad.exe"

    sGroupPath = "LDAP://ldap_server/cn=group_name,ou=OU_Name,o=O_Name"

    on error resume next
    set oGroup = getobject(sGroupPath)
    if err.number 0 then
    msgbox "The group does not exist."
    end if
    on error goto 0

    oConnection.Open "ADSI"
    set oCommand.ActiveConnection = oConnection

    arrMembers = oGroup.member

    oShell.run cNotepad

    wscript.sleep 2000
    oShell.sendkeys "************ " & sGroup & " ***************** {enter}"
    for k = lbound(arrMembers) to UBound(arrMembers)
    iComma = instr(1, arrMembers(k), ",")
    sMember = replace(left(arrMembers(k), iComma - 1), "cn=", "")
    oCommand.CommandText = ";(&(objectClass=inetorgPerson)(cn=" & sMember & "*));ADsPath;subtree"
    Set oRecordset = oCommand.Execute
    set oUser = GetObject(oRecordset.Fields("AdsPath"))
    sContext = replace(oRecordset.Fields("AdsPath"), "LDAP://ldap_server/cn=", "")
    sContext = replace(sContext, ",ou=", ".")
    sContext = replace(sContext, ",o=", ".")
    oShell.sendkeys vbtab & oUser.get("fullName") & vbtab & replace(sContext, sMember & ".", "") & vbtab & sMember & "{enter}"
    'sMsg = sMsg & oUser.get("fullName") & vbcrlf & sContext & vbcrlf & vbcrlf
    'msgbox sMsg
    'msgbox oUser.get("fullName") & vbcrlf & oRecordset.Fields("AdsPath")


    msgbox "done"
  • I am able to recreate the 52757 error if I put a trailing backslash at the end of the oNWUserGrp.fullname statement:

    Produces error:
    oNWUsrGrp.fullname = "NDS:\\---your tree name---\---your O name---\---OU that contains your groups---\"

    Does not produce error:
    oNWUsrGrp.fullname = "NDS:\\---your tree name---\---your O name---\---OU that contains your groups---"

    Hope this helps
  • Having the same '52757 - Control is not initialized' message when running this - have done the regsvr32 to register both, and had the confirmation message to say they'd been sucessfully registered.

    What could be the problem?
  • Never have used NDK until now, and I am positive that the files are registered, so any ideas as to why I get the message "52757 - Control is not initialized"