[英]How to check if the user has been added to LDAP group using springboot
我需要驗證用戶是否已成功添加到特定組。 我能想到的唯一選擇是使用異常處理。 是否有更好的方法來使用任何類型的 LDAP 響應代碼。
public boolean addMemberToGroup(String groupName, Person p) {
boolean status = false;
Name groupDn = buildGroupDn(groupName);
Name personDn = buildPersonDn(p);
try {
DirContextOperations ctx = ldapTemplate.lookupContext(groupDn);
ctx.addAttributeValue(UNIQUE_MEMBER, personDn);
ldapTemplate.modifyAttributes(ctx);
status = true;
}catch (Exception e) {
status =false;
}
return status;
}
好吧,這是我過去的處理方式:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.