我想通过使用CN获得Group DN。为此,我使用下面的代码。
public static String getGroupDNByCN(DirContext ctx, String cn) {
String groupDN = "";
String searchFilter = "(&(objectClass=group)(cn=groupCN))";
try {
SearchControls searchControls = new SearchControls();
searchControls.setSearchScope(SearchControls.SUBTREE_SCOPE);
NamingEnumeration<SearchResult> resultsGrp = ctx.search("ou=groups,o=data", searchFilter, searchControls);
while (resultsGrp.hasMoreElements()) {
SearchResult result = (SearchResult) resultsGrp.next();
Attributes attrs = result.getAttributes();
System.out.println("attrs : " + attrs);
groupDN = attrs.get("distinguishedName").get().toString();
resultsGrp.nextElement();
}
} catch (Exception e) {
System.out.println("Exception : " + e);
}
return groupDN;
}
当我运行此操作时,我在attrs
sysout
获得了以下值{owner=owner: cn=admin,ou=sa,o=system, equivalenttome=equivalentToMe: cn=ksuchostawski,ou=users,o=data, cn=lsazonova,ou=users,o=data, cn=lsazonovatest,ou=users,o=data, cn=mnewuser,ou=users,o=data, cn=mwu,ou=users,o=data, cn=nuser,ou=users,o=data, cn=rdevenyi,ou=users,o=data, cn=sbudan,ou=users,o=data, cn=sbudan1,ou=users,o=data, cn=sbudan2,ou=users,o=data, cn=sbudan21,ou=users,o=data, cn=staylor,ou=users,o=data, cn=stest,ou=users,o=data, cn=suser,ou=users,o=data, cn=cgrugina,ou=users,o=data, cn=crugina,ou=users,o=data, cn=ddev1,ou=users,o=data, cn=dpro1,ou=users,o=data, cn=dpro2,ou=users,o=data, cn=dpro21,ou=users,o=data, cn=dpro4,ou=users,o=data, cn=dpro5,ou=users,o=data, objectclass=objectClass: groupOfNames, Top, acl=ACL: 2#entry#[Root]#member, cn=cn: pcvc, member=member: cn=ksuchostawski,ou=users,o=data, cn=lsazonova,ou=users,o=data, cn=lsazonovatest,ou=users,o=data, cn=mnewuser,ou=users,o=data, cn=mwu,ou=users,o=data, cn=nuser,ou=users,o=data, cn=rdevenyi,ou=users,o=data, cn=sbudan,ou=users,o=data, cn=sbudan1,ou=users,o=data, cn=sbudan2,ou=users,o=data, cn=sbudan21,ou=users,o=data, cn=staylor,ou=users,o=data, cn=stest,ou=users,o=data, cn=suser,ou=users,o=data, cn=cgrugina,ou=users,o=data, cn=crugina,ou=users,o=data, cn=ddev1,ou=users,o=data, cn=dpro1,ou=users,o=data, cn=dpro2,ou=users,o=data, cn=dpro21,ou=users,o=data, cn=dpro4,ou=users,o=data, cn=dpro5,ou=users,o=data}
Attributes
在上面的distinguishedName
中,没有Java
属性。请帮助我如何使用CN获得Group DN。
我正在使用NetIQ eDirectory 8.8 SP8 v20810.20
和private int Total(Order order)
{
return order.qtyOrdered + order.alreadySent;
}
IQueryable<orders> query = _context.Set<orders>();
var result = query.Select(p => new{
REMAINING = Total(p),
AWATING = Total(p)
}).ToList();
。