title: Errors attempting to run XQuery scripts for single sign on into MarkLogic
body: <p>I'm working on using an xquery re-writer script to automate the login for a Single Sign-On solution. I'm starting with the Admin App Server at port 8001. In the App Server configuration I have:</p>
  <ul>
  <li>Set authentication = <code>application-level</code></li>
  <li>Set url rewriter = <code>rewriter.xqy</code></li>
  </ul>
  <p>I have also set the following <code>rewriter.xqy</code> script at the root <code>Admin/</code> directory on the server.
  As you can see, just as a simple test, I'm attempting to programmatically login as user &quot;Austin&quot; (a valid user).</p>
  <pre><code>xquery version &quot;1.0-ml&quot;;
  
  import module namespace rest = &quot;http://marklogic.com/appservices/rest&quot;
      at &quot;/MarkLogic/appservices/utils/rest.xqy&quot;;
  
  import module namespace config = &quot;http://marklogic.com/admin/endpoint-config&quot;
      at &quot;/endpoints/config.xqy&quot;;
  
  xdmp:login(&quot;Austin&quot;)
  
  return (rest:rewrite($config:OPTIONS,&quot;uri&quot;),xdmp:get-request-url())[1]
  </code></pre>
  <p>However, after recycling the webserver, I keep getting the following error when browsing to the Admin UI.<br />
  As soon as I remove the <code>xdmp</code> line, the error goes away, and I can get straight in.</p>
  <pre><code>500: Internal Server Error
  XDMP-UNEXPECTED: (err:XPST0003) Unexpected token syntax error, unexpected QName_
  In /rewriter.xqy on line 9
  
  </code></pre>
  <p>As another test, I tried to log some messages using <code>xdmp:log</code>, but those lines are also failing.<br />
  Any clue why xdmp scripts are not running successfully?</p>