本文整理汇总了Java中org.apache.directory.shared.ldap.entry.client.DefaultClientAttribute类的典型用法代码示例。如果您正苦于以下问题:Java DefaultClientAttribute类的具体用法?Java DefaultClientAttribute怎么用?Java DefaultClientAttribute使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DefaultClientAttribute类属于org.apache.directory.shared.ldap.entry.client包,在下文中一共展示了DefaultClientAttribute类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addAttribute
import org.apache.directory.shared.ldap.entry.client.DefaultClientAttribute; //导入依赖的package包/类
public void addAttribute(String dn, String attrName, String attrValue)
throws Exception {
EntryAttribute attr = new DefaultClientAttribute(attrName, attrValue);
Modification addValue = new ClientModification(
ModificationOperation.ADD_ATTRIBUTE, attr);
service.getAdminSession().modify(new DN(dn),
Collections.singletonList(addValue));
}
示例2: removeAttribute
import org.apache.directory.shared.ldap.entry.client.DefaultClientAttribute; //导入依赖的package包/类
public void removeAttribute(String dn, String attrName, String attrValue)
throws Exception {
EntryAttribute attr = new DefaultClientAttribute(attrName, attrValue);
Modification removeValue = new ClientModification(
ModificationOperation.REMOVE_ATTRIBUTE, attr);
service.getAdminSession().modify(new DN(dn),
Collections.singletonList(removeValue));
}
示例3: doPost
import org.apache.directory.shared.ldap.entry.client.DefaultClientAttribute; //导入依赖的package包/类
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
Locale locale = req.getLocale();
HttpSession session = req.getSession();
if (session == null) {
res.sendRedirect("/");
return;
}
String userid = (String) session.getAttribute("userid");
String password = StringUtils.trim(req.getParameter("password"));
if (!StringUtils.isBlank(userid) && !StringUtils.isBlank(password) && password.length() >= 8) {
try {
DefaultClientAttribute entryAttribute = new DefaultClientAttribute("userPassword", encodeForLDAP(password.trim()));
ClientModification clientModification = new ClientModification();
clientModification.setAttribute(entryAttribute);
clientModification.setOperation(ModificationOperation.REPLACE_ATTRIBUTE);
ModifyRequestImpl modifyRequest = new ModifyRequestImpl(1);
modifyRequest.setName(new LdapDN("uid=" + encodeForLDAP(userid.trim()) + ",ou=people,dc=t246osslab,dc=org"));
modifyRequest.addModification(clientModification);
EmbeddedADS.getAdminSession().modify(modifyRequest);
StringBuilder bodyHtml = new StringBuilder();
bodyHtml.append("<form>");
bodyHtml.append(getMsg("msg.passwd.changed", locale));
bodyHtml.append("<br><br>");
bodyHtml.append("<a href=\"/admins/main\">" + getMsg("label.goto.admin.page", locale) + "</a>");
bodyHtml.append("</form>");
responseToClient(req, res, getMsg("title.csrf.page", locale), bodyHtml.toString());
} catch (Exception e) {
log.error("Exception occurs: ", e);
req.setAttribute("errorMessage", getErrMsg("msg.passwd.change.failed", locale));
doGet(req, res);
}
} else {
if (StringUtils.isBlank(password) || password.length() < 8) {
req.setAttribute("errorMessage", getErrMsg("msg.passwd.is.too.short", locale));
} else {
req.setAttribute("errorMessage", getErrMsg("msg.unknown.exception.occur",
new String[] { "userid: " + userid }, locale));
}
doGet(req, res);
}
}
示例4: doPost
import org.apache.directory.shared.ldap.entry.client.DefaultClientAttribute; //导入依赖的package包/类
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
Locale locale = req.getLocale();
HttpSession session = req.getSession();
if (session == null) {
res.sendRedirect("/");
return;
}
String userid = (String) session.getAttribute("userid");
if (userid == null) {
res.sendRedirect("/");
return;
}
String mail = StringUtils.trim(req.getParameter("mail"));
if (!StringUtils.isBlank(mail) && EmailUtils.isValidEmailAddress(mail)) {
try {
DefaultClientAttribute entryAttribute = new DefaultClientAttribute("mail", encodeForLDAP(mail.trim()));
ClientModification clientModification = new ClientModification();
clientModification.setAttribute(entryAttribute);
clientModification.setOperation(ModificationOperation.REPLACE_ATTRIBUTE);
ModifyRequestImpl modifyRequest = new ModifyRequestImpl(1);
modifyRequest.setName(new LdapDN("uid=" + encodeForLDAP(userid.trim()) + ",ou=people,dc=t246osslab,dc=org"));
modifyRequest.addModification(clientModification);
EmbeddedADS.getAdminSession().modify(modifyRequest);
StringBuilder bodyHtml = new StringBuilder();
bodyHtml.append("<form>");
bodyHtml.append(getMsg("msg.mail.changed", locale));
bodyHtml.append("<br><br>");
bodyHtml.append("<a href=\"/admins/main\">" + getMsg("label.goto.admin.page", locale) + "</a>");
bodyHtml.append("</form>");
responseToClient(req, res, getMsg("title.clickjacking.page", locale), bodyHtml.toString());
} catch (Exception e) {
log.error("Exception occurs: ", e);
req.setAttribute("errorMessage", getErrMsg("msg.mail.change.failed", locale));
doGet(req, res);
}
} else {
req.setAttribute("errorMessage", getErrMsg("msg.mail.format.is.invalid", locale));
doGet(req, res);
}
}
示例5: replaceMod
import org.apache.directory.shared.ldap.entry.client.DefaultClientAttribute; //导入依赖的package包/类
private static Modification replaceMod(String attrName, String newValue) {
return new ClientModification(
REPLACE_ATTRIBUTE, new DefaultClientAttribute(attrName, newValue));
}