The first code sample shows how to enumerate numerous groups in nested organizational units. The second shows how to enumerate members of a single group in a single organizational unit.
Case 1 use ADO:
// language == JScript
var oConn = new ActiveXObject("ADODB.Connection");
oConn.Provider = "ADSDSOObject";
oConn.Open("ADs Provider");
var oRs = oConn.Execute(";(LDAP QUERY");
while (!oRs.Eof){
var oUser = GetObject(oRs.Fields("ADsPath").Value);
WScript.Echo(oUSer.Members);
oRs.MoveNext();
}
oConn.Close();
Case 2 - bind to the group using the ldap provider and get the members:
//language == JScript
var obj = GetObject_("LDAP://CN=MyUsers,CN=Users,DC=CTR1,DC=root01,DC=org");
mList = new Enumerator(obj);
for (; !mList.atEnd(); mList.moveNext())
{
s = mList.item();
WScript.Echo(s.Members);
}
Submitted by Mike Hutchins from the 15 Seconds ADSI Discussion list.