这适用于OrientDB的早期(测试版)版本,并且不再起作用。那么正确的做法是什么?
用例:创建新的(文档)数据库时,我想更改admin
用户密码。代码:
ODatabaseDocumentTx oDb = ...
if (!oDb.exists()) {
// this will create AND open the database with credentials "admin"/"admin"
oDb.create();
// the "admin" user MUST exists, otherwise it is recreated / "repaired" during login, see OSecurityShared.
// So we always use 'admin' as name and only change the password
if ("admin".equals(userName)) {
OSecurityUser admin = oDb.getUser();
admin.setPassword(password);
....
这会抛出一个 java.lang.UnsupportedOperationException
java.lang.UnsupportedOperationException: null
at
com.orientechnologies.orient.core.metadata.security.OImmutableUser.setPassword(OImmutableUser.java:132)
引入了不可变的用户来改善多线程。您始终可以获取基础文档。
试试这应该工作
ODocument admin = db.getUser().getDocument();
admin.field("password","newpassword");
admin.save();
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句