我尝试在 MarkLogic 中设置一个用户名等于电子邮件地址(“[email protected]”)的用户,似乎我可以创建用户但不能创建相应的角色。
我创建了用户,但是当我想像这样向它添加角色时:
sec.userAddRoles(user,role)
这给出了一个错误,如:
2016-03-11 20:00:48.820 Notice: api-cluey-app: in /v1/projects.sjs, at 182:26, in projPost() [javascript]
2016-03-11 20:00:48.820 Notice: api-cluey-app: in [anonymous], at 1:67,
2016-03-11 20:00:48.820 Notice: api-cluey-app: in xdmp:eval("declareUpdate(); var sec = require('/MarkLogic/security.xqy'); s...", {role:"scc-proj-8327360-owner", user:"[email protected]"}, {isolation:"different-transaction", userId:"11821709629759202109", database:"17312114676051821586"}) [javascript]
2016-03-11 20:00:48.820 Notice: api-cluey-app: in /v1/projects.sjs [javascript]
2016-03-11 20:00:48.820 Notice: api-cluey-app: in /v1/projects.sjs [javascript]
2016-03-11 20:00:49.416 Info: api-cluey-app: Status 500: XDMP-LEXVAL: sec:role-name("[email protected]") -- Invalid lexical value "[email protected]"
如果我尝试查看管理员安全数据库,情况会变得更糟:
You've encountered an error in the server. If you have a maintenance contract, you can open a support ticket by copying the text below and emailing [email protected]. Otherwise, please see our community Q & A resources for help with this issue:
500: Internal Server Error
XDMP-LEXVAL: sec:role-name("[email protected]") -- Invalid lexical value "[email protected]"
In /MarkLogic/Admin/lib/session.xqy on line 595
In get-session-role()
$role = ()
$u = fn:doc("http://marklogic.com/xdmp/roles/6750406636815962640")/sec:role
In /MarkLogic/Admin/lib/nav-format.xqy on line 2486
In role-nav("security", "summary", "role", "")
$section = "security"
$panel = "summary"
$param = "role"
$icon = ""
$t = "section=security"
$npan = "summary"
$u = fn:doc("http://marklogic.com/xdmp/roles/6966198486234205304")/sec:role
$uid = fn:doc("http://marklogic.com/xdmp/roles/6966198486234205304")/sec:role/sec:role-id
$args = "section=security&role=6966198486234205304"
$uname = sec:role-name("davida")
In /MarkLogic/Admin/lib/nav-format.xqy on line 2392
In security-nav("security", "summary", "role", "")
$section = "security"
$panel = "summary"
$param = "role"
$icon = ""
$panel = "summary"
In /MarkLogic/Admin/lib/nav-format.xqy on line 2358
In printNav("security", "summary", "role", "")
$section = "security"
$panel = "summary"
$param = "role"
$icon = ""
$sec = "security"
$start-time = xs:dayTimeDuration("PT0.001403S")
In /MarkLogic/Admin/lib/role-summary-form.xqy on line 87
In roleSummaryPage()
In /role-summary.xqy on line 16
所以我的问题是:有效的 MarkLogic 用户名和角色中允许使用哪些字符?似乎找不到任何相关文档?
最佳答案
您可以在 MarkLogic 附带的模式中找到类型定义。在 Mac 上,它们在 ~/Library/MarkLogic/Config
中;在 Linux 上, /opt/MarkLogic/Config/
。有问题的模式是 security.xsd
,它具有以下 role-name
的类型定义:
<xs:simpleType name="role-name">
<xs:annotation>
<xs:documentation>
</xs:documentation>
<xs:appinfo>
</xs:appinfo>
</xs:annotation>
<xs:restriction base="xs:NMTOKEN">
<xs:minLength value="1"/>
</xs:restriction>
</xs:simpleType>
xs:NMTOKEN
在这里定义: https://www.w3.org/TR/xml11/#NT-Nmtoken 。它是一个有效的 NameStartChar
后跟任意数量的 NameChar
。换句话说,它是一个有效的 XML 本地名称。 ( 更新 :这是不正确的;XML 本地名称比 NMTOKEN 更具限制性。)在 XQuery 中,您可以像这样检查有效名称:
"[email protected]" castable as xs:NMTOKEN
返回
false
。更新 :
抱歉,我错过了后续问题。
所有 XML 模式类型都有内置的构造函数/转换函数,它们通过对其参数应用类型转换来工作。这些类型构造器在服务器端 JS 中可用,位于全局
xs
对象下:var isValid
try {
isValid = !!xs.NMTOKEN("test%")
} catch(err) {
isValid = false
}
关于marklogic - MarkLogic 8 用户名和角色中允许使用哪些字符?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/35949461/