2015-09-07 317 views
0

我試圖使用下面的代碼更改LDAP中的用戶密碼,我不是LDAP的管理員,因此我與具有ou = systemusers的用戶建立連接它可以創建用戶,並將用戶添加到組中。我知道舊密碼的使用,將做改變使用unboundid在LDAP中更改用戶密碼

PasswordModifyExtendedRequest passwordModifyRequest = 
     new PasswordModifyExtendedRequest(
      "uid=test.user,ou=People,dc=example,dc=com", // The user to update 
      (String) null, // The current password for the user. 
      (String) null); // The new password. null = server will generate 

PasswordModifyExtendedResult passwordModifyResult; 
try 
{ 
    passwordModifyResult = (PasswordModifyExtendedResult) 
     connection.processExtendedOperation(passwordModifyRequest); 
    // This doesn't necessarily mean that the operation was successful, since 
    // some kinds of extended operations return non-success results under 
    // normal conditions. 
} 
catch (LDAPException le) 
{ 
    // For an extended operation, this generally means that a problem was 
    // encountered while trying to send the request or read the result. 
    passwordModifyResult = new PasswordModifyExtendedResult(
     new ExtendedResult(le)); 
} 

LDAPTestUtils.assertResultCodeEquals(passwordModifyResult, 
     ResultCode.SUCCESS); 
String serverGeneratedNewPassword = 
     passwordModifyResult.getGeneratedPassword(); 

但我總是得到這樣的結果。

PasswordModifyExtendedResult(resultCode=50 (insufficient access rights), messageID=4, diagnosticMessage='You do not have sufficient privileges to perform password reset operations') 

如何更改用戶密碼瞭解舊密碼?

回答

2

您必須以具有足夠特權執行操作的用戶登錄,或者更常用作爲用戶自己使用舊密碼進行登錄,當然這是額外的完整性檢查。否則,LDAP服務器配置錯誤。

+0

所以我可以更改密碼如果我登錄像用戶或我將有更多的特權。我測試了第二個,它的工作原理,但我怎麼能執行第一,如果我使用連接權利形式的池連接,做一個用戶綁定? – anquegi

+0

除非LDAP服務器配置錯誤,否則用戶應始終能夠更改自己的密碼。我不明白你的第二句話中的問題。 – EJP

+0

好的,謝謝,我說我有一個來自ou = systemusers的帳戶,但不是管理員,但似乎沒有足夠的權限來更改密碼,其他人有。 – anquegi