This [[Module Library|XQuery Module]] contains functions for creating and administering database users. The [[User Management]] article gives provides more information on database users and permissions.
=Conventions=
|- valign="top"
| '''Summary'''
|Returns the name of the currently logged -in user.
|- valign="top"
| '''Examples'''
|- valign="top"
| '''Summary'''
|Returns the names of all registered users that who are visible to the current user.
|- valign="top"
| '''Examples'''
|- valign="top"
| '''Summary'''
|Returns an element sequence, containing all registered users that who are visible to the current user.<br/>In addition to the {{Command|SHOW USERS}} command, encoded password strings and database permissions will be output. A user {{Code|$name}} can be specified to filter the results in advance.
|- valign="top"
| '''Examples'''
|
* After a fresh installation, {{Code|user:list-details()}} returns output similar to the following one:
<syntaxhighlight pre lang="xml">
<user name="admin" permission="admin">
<password algorithm="digest">
</password>
</user>
</syntaxhighlightpre>
|- valign="top"
| '''Errors'''
| width='120' | '''Signature'''
|<pre>user:check(
$name as xs:string,
$password as xs:string
) as empty-sequence()</pre>
=Updates=
'''Important note:''' All functions in this section are ''updating functions'': they will not be immediately executed, but queued on the [[XQuery Update#Pending Update List|Pending Update List]], which will be processed after the actual query has been evaluated. This means that the order in which the functions are specified in the query usually does usually not reflect the order in which the code will be evaluated.
==user:create==
| width='120' | '''Signature'''
|<pre>user:create(
$name as xs:string, $password as xs:string, $permissions as xs:string* := (), $patterns as xs:string* := (),
$info as element(info) := ()
) as empty-sequence()</pre>
| width='120' | '''Signature'''
|<pre>user:grant(
$name as xs:string, $permissions as xs:string*,
$patterns as xs:string* := ()
) as empty-sequence()</pre>
| width='120' | '''Signature'''
|<pre>user:drop(
$name as xs:string,
$patterns as xs:string* := ()
) as empty-sequence()</pre>
| width='120' | '''Signature'''
|<pre>user:alter(
$name as xs:string,
$newname as xs:string
) as empty-sequence()</pre>
| width='120' | '''Signature'''
|<pre>user:password(
$name as xs:string,
$password as xs:string
) as empty-sequence()</pre>
| width='120' | '''Signature'''
|<pre>user:update-info(
$info as element(info),
$name as xs:string := ()
) as empty-sequence()</pre>
|
* Store initial groups information:
<syntaxhighlight pre lang="'xquery"'>
user:update-info(element info {
for $group in ('editor', 'author', 'writer')
return element group { $group }
})
</syntaxhighlightpre>
* Add a group to a specific user:
<syntaxhighlight pre lang="'xquery"'>
user:update-info(<info group='editor'/>, 'john')
</syntaxhighlightpre>
|}