2

(eXist 4.4) I am working on creating a user setup page to allow an admin to create site users. I want to store info beyond user name/pword/permissions (for example email, language preference, etc). The question is where to store user info beyond what is kept in the collection /db/system/security/exist/accounts: is there a recommended secure practice for this? Is there a reason not to simply add new elements to the user profile .xml files kept in /db/system/security/exist/accounts ?

jbrehr
  • 775
  • 6
  • 19

1 Answers1

3

Several account metadata attributes from the axschema.org schema are supported by eXist. For example, given a $user record of the form:

<user>
    <friendly-name/>
    <first-name/>
    <last-name/>
    <full-name/>
    <email/>
    <country/>
    <language/>
    <timezone/>
</user>

You can set these attributes via:

sm:set-account-metadata($username, xs:anyURI("http://axschema.org/namePerson"), $user/full-name),
sm:set-account-metadata($username, xs:anyURI("http://axschema.org/namePerson/first"), $user/first-name),
sm:set-account-metadata($username, xs:anyURI("http://axschema.org/namePerson/last"), $user/last-name),
sm:set-account-metadata($username, xs:anyURI("http://axschema.org/namePerson/friendly"), $user/preferred-name),
sm:set-account-metadata($username, xs:anyURI("http://axschema.org/contact/email"), $user/email),
sm:set-account-metadata($username, xs:anyURI("http://axschema.org/contact/country/home"), $user/country),
sm:set-account-metadata($username, xs:anyURI("http://axschema.org/pref/language"), $user/language),
sm:set-account-metadata($username, xs:anyURI("http://axschema.org/pref/timezone"), $user/timezone)

Then you can retrieve these attributes using the sm:get-account-metadata() function.

See http://exist-db.org/exist/apps/fundocs/index.html?q=account-metadata for the relevant function documentation. See also https://github.com/eXist-db/exist/blob/develop/exist-core/src/main/java/org/exist/security/AXSchemaType.java for the source code.

Joe Wicentowski
  • 5,159
  • 16
  • 26