我通过使用它来获取用户的所有组
String[] attrIDs = {"cn"}; ctls.setReturningAttributes(attrIDs); String[] attributes = {"memberOf"}; ctls.setReturningAttributes(attributes); NamingEnumeration> answer = ctx.search(usersContainer, "(&(objectclass=user)(sAMAccountName=userName))", ctls);