我正在使用此站点的LDAP SDK:https://www.unboundid.com/products/ldap-sdk/.我想做一个返回很多条目的搜索操作.
根据FAQ的网站(https://www.unboundid.com/products/ldap-sdk/docs/ldapsdk-faq.php#search),我必须使用SearchResultListener实现.
所以这就是我所做的:
public class UpdateThread extends Thread implements SearchResultListener {
...
// create request
final SearchRequest request = new SearchRequest(this, instance.getBaseDN(),SearchScope.SUB, filter);
// Setting size limit of results.
request.setSizeLimit(2000);
...
// Get every result one by one.
@Override
public void searchEntryReturned(SearchResultEntry arg0) {
System.out.println("entry "+arg0.getDN());
}
Run Code Online (Sandbox Code Playgroud)
问题是"searchEntryReturned"最多返回1000个结果.即使我将大小限制设置为"2000".
我正在研究一种从AD获取用户详细信息并将其导入另一个系统的工具.我们计划使用objectSid作为唯一标识符,但我发现由于某种原因,LDAP结果中的objectSid与Active Directory中的对象不匹配.大多数字节都是相同的,但有些字节有所不同,有时LDAP结果的字节数比AD中的字节少.
AD中用户的objectSid:
decimal: [ 1, 5, 0, 0, 0, 0, 0, 5, 21, 0, 0, 0, 35, 106, 222, 96, 236, 251, 239, 68, 32, 255, 234, 203, 122, 4, 0, 0]
hex: [01, 05, 00, 00, 00, 00, 00, 05, 15, 00, 00, 00, 23, 6A, DE, 60, EC, FB, EF, 44, 20, FF, EA, CB, 7A, 04, 00, 00]
Run Code Online (Sandbox Code Playgroud)
通过LDAP结果为同一用户提供objectSid:
decimal: [ 1, 5, 0, 0, 0, 0, 0, 5, 21, 0, 0, 0, 35, 106, 63, …Run Code Online (Sandbox Code Playgroud) 我手中有一个SSL LDAP服务器证书.我想用它来使用UnboundID SDK连接到LDAP服务器.
我不想使用com.unboundid.util.ssl.TrustAllTrustManager,如下所示: 使用带有SSL证书文件的UnboundID SDK连接到Android应用程序中的LDAP服务器
以下TrustManagers不符合我们的产品要求:
com.unboundid.util.ssl.PromptTrustManager
com.unboundid.util.ssl.HostNameTrustManager
com.unboundid.util.ssl.ValidityDateTrustManager
Run Code Online (Sandbox Code Playgroud)
我不希望任何用户交互,以及我在TrustManager上面列出的验证证书颁发者的内容.
另外,我不想在任何密钥库中插入LDAP服务器证书,因此我无法使用以下TrustManagers:
com.unboundid.util.ssl.WrapperKeyManager
com.unboundid.util.ssl.PKCS11KeyManager
com.unboundid.util.ssl.KeyStoreKeyManager
Run Code Online (Sandbox Code Playgroud)
我想做类似下面的代码:
CertificateFactory cf = CertificateFactory.getInstance("X.509");
Certificate cert = cf.generateCertificate(byteArrayInputStream);
SSLUtil sslUtil = new SSLUtil(new CertificateTrustManager(cert));
SSLSocketFactory socketFactory = sslUtil.createSSLSocketFactory();
LDAPConnection connection = new LDAPConnection(socketFactory,
"server.example.com", 636);
Run Code Online (Sandbox Code Playgroud)
请注意,UnboundID SDK中不存在CertificateTrustManager.怎么可能这样做?
我从LDAP服务器导出了以下ldif文件,现在我正在尝试导入它,以便我可以复制我从中导出的目录:
dn: cn=MYCOMPANY Users,dc=mycompany,dc=com
changetype: add
objectClass: posixGroup
objectClass: top
cn: MYCOMPANY Users
gidNumber: 1001
dn: cn=jim smith,cn=MYCOMPANY Users,dc=mycompany,dc=com
objectClass: inetOrgPerson
objectClass: posixAccount
objectClass: top
givenName: jim
cn: jim smith
sn: smith
gidNumber: 1000
homeDirectory: /home/users/arolls
uid: jsmith
uidNumber: 1038
userPassword: {MD5}X03MO1qnZdYdgyfeuILPmQ==
dn: cn=dave jones,cn=MYCOMPANY Users,dc=mycompany,dc=com
objectClass: inetOrgPerson
objectClass: posixAccount
objectClass: top
givenName: dave
userPassword: {MD5}FhCDh0PMkOPk/dp0goLZuA==
loginShell: /bin/sh
cn: dave jones
sn: dave
gidNumber: 1000
homeDirectory: /home/users/dave
uid: dave
uidNumber: 1006
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用它导入它
LDIFReader r = new LDIFReader(resourceAsStream);
LDIFChangeRecord readEntry = …Run Code Online (Sandbox Code Playgroud) 我正在与Active Directory搏斗,试图让它让我更改密码.我发现了大量有用的信息,但我仍然遇到了持续的错误.
一些代码:
import com.unboundid.ldap.sdk._
import com.unboundid.util.ssl._
def main(args: Array[String]) : Unit = {
var sslUtil = new SSLUtil( new TrustAllTrustManager() )
var con = new LDAPConnection(sslUtil.createSSLSocketFactory())
con.connect("ldap.example.net", 636)
con.bind("ldapadmin", "adminpasswd")
val newPass = "Jfi8ZH8#k".getBytes("UTF-16LE");
val modRequest = new ModifyRequest("dn: cn=Tester Dude,ou=Lab,ou=Org,ou=Provider,DC=example,DC=net",
"changetype: modify",
"replace: unicodePwd",
"unicodePwd: " + '"' + newPass + '"')
println("\nGoing to try to set password to " + newPass + " with: " + modRequest.toString())
try {
con.modify(modRequest)
} catch {
case lde:LDAPException => println("failed …Run Code Online (Sandbox Code Playgroud) 我正在尝试在我的Android应用程序中建立与LDAP服务器的连接,并且正在使用UnboundID SDK.最近,从不安全的LDAP到安全的LDAP进行了更改,我必须相应地更改应用程序.我已获得SSL证书文件进行验证.我已经使用的文件,以使密钥库的描述在这里.我在我的应用程序的assets文件夹中有这个密钥库文件,并且从那里开始.下面的代码当前不起作用,并抛出异常:
LDAPException(resultCode = 01(connect error),errorMessage =('尝试连接到服务器时发生错误place.myserver.com:636:javax.net.ssl.SSLHandShakeException:java.security.cert.CertPathValidatorException:Trust anchor for未找到证书路径
// code from above link
AssetManager assetManager = getApplicationContext().getAssets();
InputStream keyStoreInputStream = assetManager.open("yourapp.store");
KeyStore trustStore = KeyStore.getInstance("BKS");
trustStore.load(keyStoreInputStream, "myPassword".toCharArray());
TrustManagerFactory tmf = TrustManagerFactory.getInstance("X509");
tmf.init(trustStore);
// my code
SSLUtil sslUtil = new SSLUtil(tmf.getTrustManagers());
LDAPConnection connection = new LDAPConnection(sslUtil.createSSLSocketFactory());
connection.connect("place.myserver.com", 636);
Run Code Online (Sandbox Code Playgroud)
但是,代码段:
SSLUtil sslUtil = new SSLUtil(new TrustAllTrustManager());
LDAPConnection connection = new LDAPConnection(sslUtil.createSSLSocketFactory());
connection.connect("place.myserver.com", 636);
Run Code Online (Sandbox Code Playgroud)
确实有效(虽然我被高层人士告知,这将是不安全的).我不太清楚我在这里做错了什么,所以任何帮助都会受到赞赏.另外,如果有一个更好的方法来完成这个比我上面尝试做的更多,请随时告诉我:)我想坚持使用UnboundID库,因为其余的代码已经使用这也是,如果我使用TrustAllTrustManager一切正常.
使用UnboundID LDAP sdk,如何获取特定用户所属的所有LDAP组?(我真的很感激一些示例代码)。
我们正在构建一个新的库,它需要对我们的主要身份管理 LDAP 系统进行读/写。
我们正在考虑使用 Spring LDAP ( http://projects.spring.io/spring-ldap/ )、UnboundId LDAP ( https://www.ldap.com/unboundid-ldap-sdk-for-java ) 或http ://www.ldaptive.org(可以使用 UnboundId LDAP)。
由于我们在使用 Spring LDAP 的项目中使用 Spring 库/框架可能更容易。
任何人都对较新版本的 Spring LDAP 或 UnboundId LDAP 有很好的经验?两者之间有什么优缺点吗?
看起来 Spring LDAP 开发已经停滞(有一段时间没有提交,版本有限)。有人知道 Spring LDAP 开发是否仍然活跃吗?
谢谢您的帮助。
布鲁斯
我试图在我的一个Spring Boot项目中使用Spring LDAP,但是运行多个测试时出现“ Address in use”错误。
我已经在这里本地克隆了示例项目:https : //spring.io/guides/gs/authenticating-ldap/
...并刚刚添加了通常由Spring Boot创建的样板测试,以验证Application Context是否正确加载:
@RunWith(SpringRunner.class)
@SpringBootTest
public class MyApplicationTests {
@Test
public void contextLoads() {
}
}
Run Code Online (Sandbox Code Playgroud)
如果单独运行,则此测试通过。一旦LdapAuthenticationTests和MyApplicationTests一起运行,我会得到上面关于后者的错误。
经过一番调试后,我发现发生这种情况是因为系统尝试生成嵌入式服务器的第二个实例。
我确定我在配置中缺少一些非常愚蠢的东西。我该如何解决这个问题?
这是要求我看到LDAP中已修改的条目已在LDAP服务器端修改过吗?Unboundid api中是否有任何api或代码,以便我可以在LDAP中看到修改后的条目?
ldap ×8
java ×4
spring-ldap ×2
ssl ×2
android ×1
certificate ×1
ldif ×1
scala ×1
spring-boot ×1
testing ×1