下面列出了怎么用javax.naming.directory.NoSuchAttributeException的API类实例代码及写法,或者点击链接到github查看源代码。
public void removeUser(String username, String groupName) throws NamingException {
try {
ModificationItem[] mods = new ModificationItem[1];
Attribute mod = new BasicAttribute("member", getUserDN(username));
mods[0] = new ModificationItem(DirContext.REMOVE_ATTRIBUTE, mod);
context.modifyAttributes(getGroupDN(groupName), mods);
} catch (NoSuchAttributeException e) {
// If user is not assigned, ignore the error
}
}