0
私はグループがDN ismemberofを使用せずにldapグループのメンバー数を取得するには?
と呼ばれています。cn = myGroupが、OU = manegedGroup、dc = example、dc = comの LDAPで、私はismemberof使用せずに、このグループのメンバーの数を取得したいです。私はdnまたはcnを必要としません、代わりにメンバーの必要はありません。
私はグループがDN ismemberofを使用せずにldapグループのメンバー数を取得するには?
と呼ばれています。cn = myGroupが、OU = manegedGroup、dc = example、dc = comの LDAPで、私はismemberof使用せずに、このグループのメンバーの数を取得したいです。私はdnまたはcnを必要としません、代わりにメンバーの必要はありません。
異なるLDAPサーバが異なるグループがメンバーを示すために属性を持つ事前に感謝します。 MSADは属性 "member"を使用し、OIDは "uniquemember"などを使用します。
メンバーの数を取得するには、グループエントリ "cn = myGroup"を検索し、 "member"属性のサイズを取得します。
擬似コード:
//Create initial dir context to dc=example,dc=com
env.put(DirContext.PROVIDER_URL, "ldap://<host>:<port>/dc=example,dc=com");
ctx = new InitialDirContext(env);
//Set returning attributes in search control
SearchControls controls = new SearchControls();
controls.setReturningAttributes(new String[] { "cn", "uniquemember"});
controls.setSearchScope(SearchControls.SUBTREE_SCOPE);
//Set search filter
String filter = "(cn=myGroup)";
//Search for the group under the correct OU passing filter and control
NamingEnumeration<SearchResult> searchResult =ctx.search("ou=manegedGroup",
filter, controls);
//Get the size of the member attributes which is count of group members
while (searchResult.hasMoreElements()) {
SearchResult ser = searchResult.next();
Attributes attribs = ser.getAttributes();
Attribute attrib = attribs.get("member");
System.out.println("member count : "+attrib.size());
}
グループのメンバーが割り当てられている方法は?グループメンバーシップはユーザーの属性ですか?または、ユーザーはグループの属性ですか? – heiglandreas