xquery version '1.0'; declare namespace xmldb = 'http://exist-db.org/xquery/xmldb'; declare namespace util = 'http://exist-db.org/xquery/util'; (: We ought to use xmldb:authenticate here, but since that doesn't seem to do what it is supposed to do, we use a bit of a hack that tries to read the /db collection with the specified username and password, and returns true when no error is thrown, and false otherwise. :) util:catch( "org.exist.xquery.XPathException", { if ( xmldb:collection( '/db', '', '' )) then "true" else "true" } , false ) { if ( xmldb:authenticate( '/db', '', '' )) then "true" else "false" }