<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.art-decor.org/index.php?action=history&amp;feed=atom&amp;title=Create_account_data_xquery</id>
	<title>Create account data xquery - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.art-decor.org/index.php?action=history&amp;feed=atom&amp;title=Create_account_data_xquery"/>
	<link rel="alternate" type="text/html" href="https://wiki.art-decor.org/index.php?title=Create_account_data_xquery&amp;action=history"/>
	<updated>2026-05-20T06:24:47Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.31.0</generator>
	<entry>
		<id>https://wiki.art-decor.org/index.php?title=Create_account_data_xquery&amp;diff=6299&amp;oldid=prev</id>
		<title>Ahenket at 14:40, 27 July 2017</title>
		<link rel="alternate" type="text/html" href="https://wiki.art-decor.org/index.php?title=Create_account_data_xquery&amp;diff=6299&amp;oldid=prev"/>
		<updated>2017-07-27T14:40:29Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 14:40, 27 July 2017&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l72&quot; &gt;Line 72:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 72:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160; &amp;#160; &amp;#160; sm:set-account-enabled($username,$account-enabled):)&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160; &amp;#160; &amp;#160; sm:set-account-enabled($username,$account-enabled):)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160; &amp;#160; &amp;#160; ,&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160; &amp;#160; &amp;#160; ,&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160; &amp;#160; &amp;#160; for $meta in $account/cfg:metadata&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160; &amp;#160; &amp;#160; for $meta in $account/cfg:metadata&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;[string-length(.) &amp;gt; 0]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160; &amp;#160; &amp;#160; return&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160; &amp;#160; &amp;#160; return&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; sm:set-account-metadata($username,xs:anyURI($meta/@key/string()),$meta/string())&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; sm:set-account-metadata($username,xs:anyURI($meta/@key/string()),$meta/string())&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Ahenket</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.art-decor.org/index.php?title=Create_account_data_xquery&amp;diff=3972&amp;oldid=prev</id>
		<title>Admin at 11:02, 24 May 2016</title>
		<link rel="alternate" type="text/html" href="https://wiki.art-decor.org/index.php?title=Create_account_data_xquery&amp;diff=3972&amp;oldid=prev"/>
		<updated>2016-05-24T11:02:09Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 11:02, 24 May 2016&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l106&quot; &gt;Line 106:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 106:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;return &amp;lt;x&amp;gt;{$create-users,$create-groups}&amp;lt;/x&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;return &amp;lt;x&amp;gt;{$create-users,$create-groups}&amp;lt;/x&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[category:xqueries]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.art-decor.org/index.php?title=Create_account_data_xquery&amp;diff=3469&amp;oldid=prev</id>
		<title>Mligtvoet at 13:54, 30 October 2015</title>
		<link rel="alternate" type="text/html" href="https://wiki.art-decor.org/index.php?title=Create_account_data_xquery&amp;diff=3469&amp;oldid=prev"/>
		<updated>2015-10-30T13:54:51Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 13:54, 30 October 2015&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot; &gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;For importing usergroup information during an eXist-db upgrade this xquery sets all user groups and meta-information for each user.&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;For importing usergroup information during an eXist-db upgrade this xquery sets all user groups and meta-information for each user.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;This xquery will perform the following actions:&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;* Create all groups that do not exist yet with descriptions, group managers.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;* Create users with password, primairy group, meta-data and activation status.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;* Set permissions on /db/apps/xis-data/accounts/* recursively: 0770 on collections and 0660 on documents.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;To run the xquery below on the server:&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;To run the xquery below on the server:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Mligtvoet</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.art-decor.org/index.php?title=Create_account_data_xquery&amp;diff=3466&amp;oldid=prev</id>
		<title>Mligtvoet: initial setup</title>
		<link rel="alternate" type="text/html" href="https://wiki.art-decor.org/index.php?title=Create_account_data_xquery&amp;diff=3466&amp;oldid=prev"/>
		<updated>2015-10-30T13:42:19Z</updated>

		<summary type="html">&lt;p&gt;initial setup&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;For importing usergroup information during an eXist-db upgrade this xquery sets all user groups and meta-information for each user.&lt;br /&gt;
&lt;br /&gt;
To run the xquery below on the server:&lt;br /&gt;
{{:run xquery}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
xquery version &amp;quot;1.0&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
declare namespace cfg = &amp;quot;http://exist-db.org/Configuration&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
declare function local:setPermissions($path as xs:string, $user as xs:string, $grp as xs:string, $grpperm as xs:string, $resprm as xs:string) {&lt;br /&gt;
   sm:chown(xs:anyURI($path),$user),&lt;br /&gt;
   sm:chgrp(xs:anyURI($path),$grp),&lt;br /&gt;
   sm:chmod(xs:anyURI($path),sm:octal-to-mode($grpperm)),&lt;br /&gt;
   sm:clear-acl(xs:anyURI($path)),&lt;br /&gt;
   for $file in xmldb:get-child-resources(xs:anyURI($path))&lt;br /&gt;
   return (&lt;br /&gt;
      sm:chown(xs:anyURI(concat($path,&amp;#039;/&amp;#039;,$file)),$user),&lt;br /&gt;
      sm:chgrp(xs:anyURI(concat($path,&amp;#039;/&amp;#039;,$file)),$grp),&lt;br /&gt;
      sm:chmod(xs:anyURI(concat($path,&amp;#039;/&amp;#039;,$file)),sm:octal-to-mode($resprm)),&lt;br /&gt;
      sm:clear-acl(xs:anyURI(concat($path,&amp;#039;/&amp;#039;,$file)))&lt;br /&gt;
   )&lt;br /&gt;
   ,&lt;br /&gt;
   for $collection in xmldb:get-child-collections($path)&lt;br /&gt;
   return&lt;br /&gt;
   local:setPermissions(concat($path,&amp;#039;/&amp;#039;,$collection),$user,$grp,$grpperm,$resprm)&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
let $excludeaccounts:= (&amp;#039;SYSTEM&amp;#039;,&amp;#039;admin&amp;#039;,&amp;#039;guest&amp;#039;,&amp;#039;xis-webservice&amp;#039;)&lt;br /&gt;
let $excludegroups  := (&amp;#039;dba&amp;#039;,&amp;#039;decor&amp;#039;,&amp;#039;decor-admin&amp;#039;,&amp;#039;terminology&amp;#039;,&amp;#039;issues&amp;#039;,&amp;#039;editor&amp;#039;,&amp;#039;tools&amp;#039;,&amp;#039;debug&amp;#039;)&lt;br /&gt;
let $descriptionkey := &amp;#039;http://exist-db.org/security/description&amp;#039;&lt;br /&gt;
let $account-data   := doc(&amp;#039;/db/apps/accounts.xml&amp;#039;)/x&lt;br /&gt;
&lt;br /&gt;
let $create-groups  :=&lt;br /&gt;
    for $groupaccount in $account-data/groups/cfg:group[not(cfg:name=$excludegroups)][not(cfg:name=$account-data/users/cfg:account/cfg:name)]&lt;br /&gt;
    let $groupname          := $groupaccount/cfg:name&lt;br /&gt;
    let $groupdesc          := $groupaccount/cfg:metadata[@key=$descriptionkey]&lt;br /&gt;
    &lt;br /&gt;
    let $group-created      := if (not(sm:group-exists($groupname))) then (sm:create-group($groupname),true()) else (false())&lt;br /&gt;
    &lt;br /&gt;
    return (&lt;br /&gt;
        if ($groupdesc) then sm:set-group-metadata($groupname,$descriptionkey,$groupdesc) else ()&lt;br /&gt;
        ,&lt;br /&gt;
        &amp;lt;group username=&amp;quot;{$groupname}&amp;quot; created=&amp;quot;{$group-created}&amp;quot;/&amp;gt;&lt;br /&gt;
    )&lt;br /&gt;
&lt;br /&gt;
let $create-users   := &lt;br /&gt;
    for $account in $account-data/users/cfg:account[not(cfg:name=$excludeaccounts)]&lt;br /&gt;
    let $username           := $account/cfg:name/string()&lt;br /&gt;
    let $password           := $account/cfg:name/string()&lt;br /&gt;
    let $primary-group      := $account-data/users/cfg:primary-group[@user=$username]/@primarygroup/string()&lt;br /&gt;
    let $account-enabled    := $account/cfg:enabled/string()&lt;br /&gt;
    let $groups             := $account/cfg:group/@name/string()&lt;br /&gt;
    &lt;br /&gt;
    let $pw         :=  $account/cfg:password/string()&lt;br /&gt;
    let $digest-pw  :=  $account/cfg:digestPassword/string()&lt;br /&gt;
    &lt;br /&gt;
    let $user-created       := if (not(sm:user-exists($username))) then sm:create-account($username,$password,$groups) else (false())&lt;br /&gt;
    &lt;br /&gt;
    return (&lt;br /&gt;
        for $group in $groups[not(.=sm:get-user-groups($username))]&lt;br /&gt;
        return&lt;br /&gt;
            sm:add-group-member($group,$username)&lt;br /&gt;
        ,&lt;br /&gt;
        sm:set-user-primary-group($username,$primary-group)&lt;br /&gt;
        (:,&lt;br /&gt;
        sm:set-account-enabled($username,$account-enabled):)&lt;br /&gt;
        ,&lt;br /&gt;
        for $meta in $account/cfg:metadata&lt;br /&gt;
        return&lt;br /&gt;
            sm:set-account-metadata($username,xs:anyURI($meta/@key/string()),$meta/string())&lt;br /&gt;
        ,&lt;br /&gt;
        update value doc(concat(&amp;#039;/db/system/security/exist/accounts/&amp;#039;,$username,&amp;#039;.xml&amp;#039;))/cfg:account/cfg:password with $pw&lt;br /&gt;
        ,&lt;br /&gt;
        if (string-length($digest-pw)&amp;gt;0) then (&lt;br /&gt;
            if (not(doc(concat(&amp;#039;/db/system/security/exist/accounts/&amp;#039;,$username,&amp;#039;.xml&amp;#039;))/cfg:account/cfg:digestPassword)) then&lt;br /&gt;
                update insert &amp;lt;digestPassword/&amp;gt; following doc(concat(&amp;#039;/db/system/security/exist/accounts/&amp;#039;,$username,&amp;#039;.xml&amp;#039;))//cfg:account[1]/cfg:password[last()]&lt;br /&gt;
            else ()&lt;br /&gt;
            ,&lt;br /&gt;
            update value doc(concat(&amp;#039;/db/system/security/exist/accounts/&amp;#039;,$username,&amp;#039;.xml&amp;#039;))/cfg:account/cfg:digestPassword with $digest-pw&lt;br /&gt;
        )&lt;br /&gt;
        else ()&lt;br /&gt;
        ,&lt;br /&gt;
        &amp;lt;user username=&amp;quot;{$username}&amp;quot; created=&amp;quot;{$user-created}&amp;quot;/&amp;gt;&lt;br /&gt;
    )&lt;br /&gt;
    &lt;br /&gt;
let $add-group-managers  :=&lt;br /&gt;
    for $groupaccount in $account-data/groups/cfg:group[not(cfg:name=$excludegroups)]&lt;br /&gt;
    let $groupname          := $groupaccount/cfg:name&lt;br /&gt;
    return (&lt;br /&gt;
        for $groupmanager in $groupaccount/cfg:manager[not(@name=sm:get-group-managers($groupname))]&lt;br /&gt;
        return&lt;br /&gt;
            sm:add-group-manager($groupname,$groupmanager/@name)&lt;br /&gt;
    )&lt;br /&gt;
    &lt;br /&gt;
let $setXisAccountsPermissions  :=&lt;br /&gt;
    for $xis-account in xmldb:get-child-collections(&amp;#039;/db/apps/xis-data/accounts&amp;#039;)&lt;br /&gt;
    return&lt;br /&gt;
        local:setPermissions(concat(&amp;#039;xmldb:exist:///db/apps/xis-data/accounts/&amp;#039;,$xis-account),&amp;#039;admin&amp;#039;,$xis-account,&amp;#039;0770&amp;#039;,&amp;#039;0660&amp;#039;)&lt;br /&gt;
    &lt;br /&gt;
return &amp;lt;x&amp;gt;{$create-users,$create-groups}&amp;lt;/x&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mligtvoet</name></author>
		
	</entry>
</feed>