<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head profile="http://internetalchemy.org/2003/02/profile"> <link rel="foaf" type="application/rdf+xml" title="FOAF" href="http://www.openlinksw.com/dataspace/uda/about.rdf" /> <link rel="schema.dc" href="http://purl.org/dc/elements/1.1/" /> <meta name="dc.title" content="10. Database Event Hooks" /> <meta name="dc.subject" content="10. Database Event Hooks" /> <meta name="dc.creator" content="OpenLink Software Documentation Team ; " /> <meta name="dc.copyright" content="OpenLink Software, 1999 - 2009" /> <link rel="top" href="index.html" title="OpenLink Virtuoso Universal Server: Documentation" /> <link rel="search" href="/doc/adv_search.vspx" title="Search OpenLink Virtuoso Universal Server: Documentation" /> <link rel="parent" href="hooks.html" title="Chapter Contents" /> <link rel="prev" href="sqlparsetree.html" title="SQL Parse Tree" /> <link rel="next" href="assocauxdata.html" title="Associating Auxiliary Data With A Connection" /> <link rel="shortcut icon" href="../images/misc/favicon.ico" type="image/x-icon" /> <link rel="stylesheet" type="text/css" href="doc.css" /> <link rel="stylesheet" type="text/css" href="/doc/translation.css" /> <title>10. Database Event Hooks</title> <meta http-equiv="Content-Type" content="text/xhtml; charset=UTF-8" /> <meta name="author" content="OpenLink Software Documentation Team ; " /> <meta name="copyright" content="OpenLink Software, 1999 - 2009" /> <meta name="keywords" content="" /> <meta name="GENERATOR" content="OpenLink XSLT Team" /> </head> <body> <div id="header"> <a name="fn_davlogins" /> <img src="../images/misc/logo.jpg" alt="" /> <h1>10. Database Event Hooks</h1> </div> <div id="navbartop"> <div> <a class="link" href="hooks.html">Chapter Contents</a> | <a class="link" href="sqlparsetree.html" title="SQL Parse Tree">Prev</a> | <a class="link" href="assocauxdata.html" title="Associating Auxiliary Data With A Connection">Next</a> </div> </div> <div id="currenttoc"> <form method="post" action="/doc/adv_search.vspx"> <div class="search">Keyword Search: <br /> <input type="text" name="q" /> <input type="submit" name="go" value="Go" /> </div> </form> <div> <a href="http://www.openlinksw.com/">www.openlinksw.com</a> </div> <div> <a href="http://docs.openlinksw.com/">docs.openlinksw.com</a> </div> <br /> <div> <a href="index.html">Book Home</a> </div> <br /> <div> <a href="contents.html">Contents</a> </div> <div> <a href="preface.html">Preface</a> </div> <br /> <div class="selected"> <a href="hooks.html">Database Event Hooks</a> </div> <br /> <div> <a href="fn_dbev_startup.html">Database Startup</a> </div> <div> <a href="fn_dbev_connect.html">Database Connections</a> </div> <div> <a href="fn_logins.html">Database Logins</a> </div> <div> <a href="fn_disconnect.html">Database Disconnections</a> </div> <div> <a href="fn_dbev_shutdown.html">Database Shutdown</a> </div> <div> <a href="fn_dbev_prepare.html">SQL Statement Preparation</a> </div> <div> <a href="sqlparsetree.html">SQL Parse Tree</a> </div> <div class="selected"> <a href="fn_davlogins.html">WebDAV Logins</a> </div> <div> <a href="assocauxdata.html">Associating Auxiliary Data With A Connection</a> </div> <br /> </div> <div id="text"> <a name="fn_davlogins" /> <h2>10.8. WebDAV Logins</h2> <p> <span class="computeroutput">DB.DBA.DBEV_DAV_LOGIN (<span class="paramdef">inout <span class="parameter">user_name</span> varchar</span>, <span class="paramdef">in <span class="parameter">password</span> varchar</span>, <span class="paramdef">in <span class="parameter">http_auth</span> any</span>); </span> </p> <p>This function, if defined, will always be called by Virtuoso just before a HTTP client is authenticated against the WebDAV Server. Three parameters are available for audit purposes or any other pre-processing purpose totally user definable.</p> <ul> <li> <strong>user_name:</strong> <ul> <li> <strong>IN</strong> : the user name from the login data</li> <li> <strong>OUT</strong> : the user name used by WebDAV server for this request</li> </ul> </li> <li> <strong>password</strong> : the encrypted password that corresponding to the user_name </li> <li> <strong>http_auth</strong> : HTTP authentication information (see below)</li> </ul> <p> The data structure of the <span class="computeroutput">http_auth</span> is an array containing name/value pairs as described below. </p> <p> For HTTP Basic authentication: </p> <ul> <li>method - HTTP method : GET/POST/PUT etc.</li> <li>authtype - string 'Basic'</li> <li>username - the same as user_name parameter</li> <li>pass - the password (in case of basic authentication only)</li> </ul> <p> For HTTP Digest authentication: </p> <ul> <li>method - HTTP method : GET/POST/PUT etc.</li> <li>authtype - string 'Digest'</li> <li>username - the same as user_name parameter</li> <li>realm - authentication realm</li> <li>qop - Indicates what "quality of protection" the client has applied to the message</li> <li>algorithm - hashing algorithm used to create the checksum or digest</li> <li>uri - the URI from Request-URI of the Request-Line</li> <li>nonce - data string which may be uniquely generated</li> <li>nc - The nc-value is the hexadecimal count of the number of requests (including the current request)</li> <li>cnonce - The cnonce-value is an opaque quoted string value provided by the client</li> <li>opaque - string value provided by the server and returned by the client unchanged</li> <li>response - string containing password hash as described in RFC 2617</li> </ul> <p>An example of the <span class="computeroutput">http_auth</span> value:</p> <div> <pre class="programlisting"> vector ('method', 'GET', 'authtype', 'basic', 'username', 'MyUser', 'pass', 'My!Secret') </pre> </div> <p>This hook can be used to control how Virtuoso proceeds with the WebDAV client login by responding to 3 possible return values:</p> <ul> <li>-1 - continue with normal verification</li> <li>0 - reject the login</li> <li>1 - allow the login (the user returned should be a valid Virtuoso local user name)</li> </ul> <a name="ex_dbev_dav_login" /> <div class="example"> <div class="exampletitle">Sample WebDAV Login Hook</div> <div> <pre class="programlisting"> create procedure DB.DBA.DBEV_DAV_LOGIN (inout user_name varchar, in pwd any, in auth any) { declare result any; WHENEVER SQLSTATE '28000' GOTO validation_failure; -- All accounts that are not WebDAV admin are going here if (lcase(user_name) <> 'dav') { declare pass any; -- use password from request if basic HTTP authentication is used if (get_keyword ('authtype', auth) = 'basic') pass := get_keyword ('pass', auth); else -- or use the password from database if digest pass := pwd_magic_calc (user_name, pwd, 1); -- set appropriate LDAP protocol version connection_set ('LDAP_VERSION', 2); commit work; result := LDAP_SEARCH('ldap://mail2.openlinksw.com:389', 0, 'ou=Accounts, o=OpenLink Software, c=US', sprintf ('(uid=%s)', user_name), sprintf('uid=%s, ou=Accounts, o=OpenLink Software, c=US', user_name), pass); return 1; } -- normal authentication for WebDAV admin return -1; -- all accounts that are not authenticated by LDAP are rejected validation_failure: return 0; }; </pre> </div> </div> <table border="0" width="90%" id="navbarbottom"> <tr> <td align="left" width="33%"> <a href="sqlparsetree.html" title="SQL Parse Tree">Previous</a> <br />SQL Parse Tree</td> <td align="center" width="34%"> <a href="hooks.html">Chapter Contents</a> </td> <td align="right" width="33%"> <a href="assocauxdata.html" title="Associating Auxiliary Data With A Connection">Next</a> <br />Associating Auxiliary Data With A Connection</td> </tr> </table> </div> <div id="footer"> <div>Copyright© 1999 - 2009 OpenLink Software All rights reserved.</div> <div id="validation"> <a href="http://validator.w3.org/check/referer"> <img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="88" /> </a> <a href="http://jigsaw.w3.org/css-validator/"> <img src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!" height="31" width="88" /> </a> </div> </div> </body> </html>