Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>There are a few parts to this question</p> <ul> <li>Programmatically Accessing Items using Sitecore Database</li> <li>Sitecore Security</li> <li>WCF &amp; Sitecore HTTPContext</li> </ul> <p>Programmatically Accessing Items using Sitecore Database <br/></p> <ul> <li>Creating a WCF service to use with reading/editing Sitecore items would require accessing the Sitecore database, see <a href="https://stackoverflow.com/questions/3234832/how-can-i-login-programatically-into-sitecore">Programmatically Login into Sitecore</a></li> <li>(As already mentioned), using <code>Sitecore.Configuration.Factory.GetDatabase(Database)</code> explicitly will get you the database, however that brings up issue number 2. </li> <li>To take advantage of built in Sitecore functionality, it's more flexible to use the <code>Sitecore.Context.ContentDatabase</code> or <code>Sitecore.Context.Database</code> methods to return the proper database based on the context in which the request is made; CD, CM server, etc.<br/> </li> </ul> <p>Security</p> <ul> <li><p>While the security disabler will work to remove all security issues with accessing the Sitecore Database it's not recommended. <a href="http://sitecore.alexiasoft.nl/2005/12/24/sitecore-security-i-do-it-my-way/" rel="nofollow noreferrer">Alex Soft and Sitecore Security</a></p> <pre class="lang-cs prettyprint-override"><code>using (new SC.Security.Accounts.UserSwitcher(User.FromName(ServiceAccountName, true))) { // code here } </code></pre></li> </ul> <p>more properly aligns with <a href="http://sdn.sitecore.net/upload/sitecore6/sc61keywords/security_api_cookbook_usletter.pdf" rel="nofollow noreferrer">Sitecore's Security API</a>, provides a security trail of transactions and enables versioning of changed items completed by the services. Such information will help with bug tracking and auditing. </p> <p>WCF and the Sitecore HTTPContext: </p> <ul> <li>You may run into issues with using WCF and objects that use the Sitecore HTTPContext.</li> <li>If you want to use <code>Sitecore.Context.ContentDatabase</code> or <code>Sitecore.Context.Database</code> in your WCF service, you'll likely get an null exceptions from the Database, especially if running the service on a CD instance. </li> <li>The one liner golden egg to overcoming this limitation is to set the Active site using <code>Sitecore.Context.SetActiveSite(SiteName)</code>, at some point in the service, (usually the constructor).</li> <li>The SiteName is name of the list of site's available in the Sitecore/Sites section of the web.config. </li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload