Sub worker_2_ChoiceList(fieldname, choices)
' fieldname As String
' choices As Object
' record type name is 测试管理
' field name is worker
REM use choices.AddItem("value") repeatedly to construct the choice list. Example:
REM choices.AddItem("red")
REM choices.AddItem("green")
REM choices.AddItem("blue")
Set queryObj = sessionObj.BuildQuery("users")
' have the query return the desired field of the user object(s)
queryObj.BuildField ("login_name")
' filter for members of group "Developer" (whatever group you want)
Set filterObj = queryObj.BuildFilterOperator(AD_BOOL_OP_AND)
filterObj.BuildFilter "groups", AD_COMP_OP_EQ, "guest"
Set resultSetObj = sessionObj.BuildResultSet(queryObj)
' run it
resultSetObj.Execute
' add each value in the returned column to the choicelist
Do While resultSetObj.MoveNext = AD_SUCCESS
choices.AddItem resultSetObj.GetColumnValue(1)
Loop
End Sub