- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
<p>DirContext ldapContext;</p>
<p>String baseName = "dc=MyCompany,dc=com";</p>
<p>String serverIP = "xx.xxx.xxx.xxx";</p>
<p>public ADConnection() {</p>
<pre><code>try {
Hashtable ldapEnv = new Hashtable(11);
ldapEnv.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
ldapEnv.put(Context.PROVIDER_URL, "ldap://xx.xx.xx.xx:389");
ldapEnv.put(Context.SECURITY_AUTHENTICATION, "simple");
ldapEnv.put(Context.SECURITY_PRINCIPAL, "cn=Directory Manager");
ldapEnv.put(Context.SECURITY_CREDENTIALS, "xxxx");
ldapContext = new InitialDirContext(ldapEnv);
System.out.println(ldapContext);
}
catch (Exception e) {
System.out.println(" bind error: " + e);
e.printStackTrace();
System.exit(-1);
}
</code></pre>
<p>}</p>
public void createNew(String username, String surname, String givenName) {
try {
String distinguishedName = "cn=" + username + baseName;
Attributes newAttributes = new BasicAttributes(true);
Attribute oc = new BasicAttribute("objectclass");
oc.add("top");
oc.add("person");
oc.add("organizationalperson");
oc.add("user");
newAttributes.put(oc);
newAttributes.put(new BasicAttribute("sAMAccountName", username));
newAttributes.put(new BasicAttribute("userPrincipalName", username + "@" + serverIP));
newAttributes.put(new BasicAttribute("cn", username));
newAttributes.put(new BasicAttribute("sn", surname));
newAttributes.put(new BasicAttribute("givenName", givenName));
newAttributes.put(new BasicAttribute("displayName", givenName + " " + surname));
System.out.println("Name: " + username + " Attributes: " + newAttributes);
ldapContext.createSubcontext(distinguishedName, newAttributes);
}
catch (Exception e) {
System.out.println("create error: " + e);
e.printStackTrace();
System.exit(-1);
}
}
public Attributes fetch(String username) {
Attributes attributes = null;
try {
System.out.println("fetching: " + username);
DirContext o = (DirContext)ldapContext.lookup("cn=" + username+ baseName);
System.out.println("search done\n");
attributes = o.getAttributes("");
for (NamingEnumeration ae = attributes.getAll(); ae.hasMoreElements();) {
Attribute attr = (Attribute)ae.next();
String attrId = attr.getID();
for (NamingEnumeration vals = attr.getAll(); vals.hasMore();) {
String thing = vals.next().toString();
System.out.println(attrId + ": " + thing);
}
}
}
catch (Exception e) {
System.out.println(" fetch error: " + e);
System.exit(-1);
}
return attributes;
}
public static void main(String[] args) {
adc.createNew("user1,", "User", "user1");
Attributes a = adc.fetch("user1,");
}
while creating user and after fetching user I am getting below error in the console.
javax.naming.directory.InitialDirContext@18eb9e6
Name: user1, Attributes: {displayname=displayName: user1 User, givenname=givenName: user1,
objectclass=objectclass: top, person, organizationalperson, user,
samaccountname=sAMAccountName: user1,, sn=sn: User, userprincipalname=userPrincipalName:
user1,@xx.xxx.xxx.xxx, cn=cn: user1,}
create error: javax.naming.NameNotFoundException: [LDAP: error code 32 - The provided entry
cn=user1,dc=MyCompany,dc=com cannot be added because its suffix is not defined as one of the
suffixes within the Directory Server]; remaining name 'cn=user1,dc=MyCompany,dc=com'
javax.naming.NameNotFoundException: [LDAP: error code 32 - The provided entry
cn=user1,dc=MyCompany,dc=com cannot be added because its suffix is not defined as one of the
suffixes within the Directory Server]; remaining name 'cn=user1,dc=MyCompany,dc=com'
最佳答案
dc=mycompany,dc=com
的后端是否存在?如果没有,您必须创建它并至少填充基础对象 dc=mycompany,dc=com
。
关于java - 无法在 Java 中从 OpenDS Activity 目录创建和获取用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11723120/
两天前我刚刚收到此要求,这是我第一次使用 LDAP(openDS)。事实上,我用于研发的时间非常有限。我已经尽可能详细地阅读了 openDS 的开发人员指南和 SDK Api。 基本上我有一个非常简单
我需要以编程方式向 openDS 服务器添加一些用户帐户,但即使在查看 openDS wiki 后我也不知道该怎么做。 。有人可以帮助我吗? 最佳答案 下面的代码使用jndi。这只会添加一个带有提供的
再次遇到opends问题 现在我想将 unicode 保存在 opends 目录中,它可以保存但是当我获取结果时 unicode 字符没有按原样显示 提前致谢 肉山 最佳答案 OpenDS 像任何 L
我想配置 OpenDS LDAP 服务器以与内存后端数据库配合使用,以进行单元测试。根据 OpedDS wiki 可以做到,但那里没有教程。 如何配置? 最佳答案 您需要内存后端,如“org.open
我在 linux redhat 6 机器上运行 opends 服务器 (2.2.0),在提示命令“status”时低于服务器的当前状态 尝试使用命令“netstat”检查此机器上监听的端口时,此处未列
嗨,请说明使用哪个 OpenDS OpenDJ OpenAM。谢谢。 最佳答案 OpenDJ 是一个构建 LDAP 和 REST 基础目录服务的开源项目。 OpenDJ 正在继续开源 OpenDS 的
我正在尝试为我的 .Net 应用程序构建一个功能,以便能够与 LDAP 服务器对话以读取用户属性并验证用户身份。我已经使用 OpenDS 设置了一个测试目录服务器,添加了自定义属性和对象,并添加了具有
我一直试图找到一些关于如何使用 .NET 的 LDAP 类型连接到 OpenDS 的教程,但没有成功。任何人都可以向我指出一些文章/教程,其中包含有关将 OpenDS 用作目录服务以及使用 C# 访问
OpenDS 上有一个密码策略,可以防止多次登录失败。如果用户成功超过限制,LDAP服务器的日志将显示,即: [17/Oct/2009:17:51:11 +0200] BIND RES conn=91
DirContext ldapContext; String baseName = "dc=MyCompany,dc=com"; String serverIP = "xx.xxx.xxx.xxx";
我的方法是 public FilteredUIExcessList getCustomerExcesses(Long cif,String primaryCO) throws Exception {
我对 Python 和 Mailchimp API 都是初学者,所以我非常需要你的建议。 我的目标是从 MailChimp 获取事件报告,其中包含以下格式的数据: 电子邮件 ----- 电子邮件打开日
我是一名优秀的程序员,十分优秀!