我正在嘗試通過JNDI更改用戶密碼,但出現以下錯誤。如何通過JNDI更改LDAP密碼
javax.naming.directory.SchemaViolationException:[LDAP:error code 65 - Entry uid = yiwei,ou =管理員,o = SID,dc = QuizPortal不能被修改,因爲結果項會違反服務器模式: Entry uid = yiwei,ou =管理員,o = SID,dc = QuizPortal違反了Directory Server模式配置,因爲它包含了該條目中定義的任何對象類所不允許的屬性用戶密碼];
以下是我的代碼。
public class ModifyAtt
{
public static String INITCTX = "com.sun.jndi.ldap.LdapCtxFactory";
public static String MY_HOST = "ldap://KhooGP-Comp1:1389/dc=QuizPortal";
public static String MGR_DN = "cn=Directory Manager";
public static String MGR_PW = "password";
public static void main(String[] args)
{
//Identify service provider to use
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, INITCTX);
env.put(Context.PROVIDER_URL, MY_HOST);
env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_PRINCIPAL, MGR_DN);
env.put(Context.SECURITY_CREDENTIALS, MGR_PW);
try
{
// Create the initial directory context
InitialDirContext initialContext = new InitialDirContext(env);
DirContext ctx = (DirContext)initialContext;
System.out.println("Context Sucessfully Initialized");
ModificationItem[] mods = new ModificationItem[1];
Attribute mod0 = new BasicAttribute("user password", "a");
mods[0] = new ModificationItem(DirContext.REPLACE_ATTRIBUTE, mod0);
ctx.modifyAttributes("uid=yiwei,ou=Administrator,o=SID", mods);
}
catch(Exception e)
{
System.err.println(e);
}
}
}
任何想法爲什麼?非常感謝提前..
凱文
你可以發佈一個附加到答案的示例代碼嗎? – Sachith 2016-06-25 11:49:32