<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="http://syndication.webwiz.co.uk/rss_namespace/">
 <channel>
  <title>DevForce Community Forum : Login Exception with IEntityLoginManager</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2009 : Login Exception with IEntityLoginManager</description>
  <pubDate>Tue, 28 Apr 2026 00:26:18 -700</pubDate>
  <lastBuildDate>Tue, 02 Dec 2008 06:20:58 -700</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 9.69</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>www.ideablade.com/forum/RSS_post_feed.asp?TID=1009</WebWizForums:feedURL>
  <image>
   <title>DevForce Community Forum</title>
   <url>http://www.ideablade.com/forum/forum_images/IdeaBlade_logo_tm.png</url>
   <link>http://www.ideablade.com/forum/</link>
  </image>
  <item>
   <title>Login Exception with IEntityLoginManager : That makes sense, thanks Greg....</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1009&amp;PID=3669#3669</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=399" rel="nofollow">LesleySastro</a><br /><strong>Subject:</strong> 1009<br /><strong>Posted:</strong> 02-Dec-2008 at 6:20am<br /><br />That makes sense, thanks Greg. Like you said in DevForce Classic I used the PersistenceManager directly passed into Login(). I also tried those two options (direct casting and parameterless constructor) with both giving me the aforementioned exception, that's why&nbsp;I was a little bit clueless.&nbsp;So the trick for me is actually using <DIV>&nbsp;</DIV><DIV>var manager = new DomainModelEntityManager(pManager);</DIV><DIV>&nbsp;</DIV><DIV>And that did it. </DIV><DIV>&nbsp;</DIV><DIV>Will I have the same kind of problems with the implementation of IEntityServerSaving? I'm using this to implement an Audit Trail feature, and I have the following code</DIV><DIV>&nbsp;</DIV><DIV><FONT size=2><P></FONT><FONT color=#0000ff size=2>var</FONT><FONT size=2> manager = args.GetEntityManager();</P><DIV></FONT><FONT color=#0000ff size=2>var</FONT><FONT size=2> changedEntities = manager.FindEntities(</FONT><FONT color=#2b91af size=2>EntityState</FONT><FONT size=2>.Added | </FONT><FONT color=#2b91af size=2>EntityState</FONT><FONT size=2>.Modified | </FONT><FONT color=#2b91af size=2>EntityState</FONT><FONT size=2>.Deleted);</DIV><P></FONT><FONT color=#0000ff size=2>foreach</FONT><FONT size=2> (</FONT><FONT color=#0000ff size=2>var</FONT><FONT size=2> entity </FONT><FONT color=#0000ff size=2>in</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>new</FONT><FONT size=2> </FONT><FONT color=#2b91af size=2>IterIsolate</FONT><FONT size=2>(changedEntities))</P><P>{</FONT><FONT color=#008000 size=2>// Check if it is an Auditable entity</P></FONT><FONT size=2><P></FONT><FONT color=#0000ff size=2>if</FONT><FONT size=2> (entity.GetType().IsAssignableFrom(</FONT><FONT color=#0000ff size=2>typeof</FONT><FONT size=2>(</FONT><FONT color=#2b91af size=2>AuditableEntity</FONT><FONT size=2>)))</P><P>{</P><P></FONT><FONT color=#008000 size=2>// If so, invoke the audit trail process</P></FONT><FONT size=2><P>((</FONT><FONT color=#2b91af size=2>AuditableEntity</FONT><FONT size=2>) entity).AuditSelf((<FONT color=#2b91af>DomainModelEntityManager</FONT>) manager, args.Principal);</P><P>}</P><P>}</P></FONT></DIV>]]>
   </description>
   <pubDate>Tue, 02 Dec 2008 06:20:58 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1009&amp;PID=3669#3669</guid>
  </item> 
  <item>
   <title>Login Exception with IEntityLoginManager : You can&amp;#039;t access the back-end...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1009&amp;PID=3667#3667</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=4" rel="nofollow">GregD</a><br /><strong>Subject:</strong> 1009<br /><strong>Posted:</strong> 01-Dec-2008 at 3:06pm<br /><br />You can't access the back-end datastore with an unauthenticated EntityManager unless it knows it's a server-side EntityManager.&nbsp; The EntityManager that's passed into the Login() method is a server-side one, but it lacks the static EntityQuery properties (e.g., em1.Users) that your specialized EntityManager type (e.g., DomainModelEntityManager) includes. So you have a couple of choices:<DIV>&nbsp;</DIV><DIV>&nbsp;&nbsp;&nbsp;&nbsp; 1. Use the ExecuteQuery&lt;T&gt;() method on the provided EntityManager to execute your query, or</DIV><DIV>&nbsp;&nbsp;&nbsp;&nbsp; 2. Create a specialized DomainModelEntityManager using the constructor that takes another EntityManager as a parameter, and forward the one passed to Login().</DIV><DIV>&nbsp;</DIV><DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DomainModelEntityManager manager = new DomainModelEntityManager(pManager);</DIV><DIV>&nbsp;</DIV><DIV>Then you can use invoke the manager.Users property.</DIV><DIV>&nbsp;</DIV><DIV>My guess is that in v3 you used (directly) the PersistenceManager that was passed into Login().</DIV><DIV>&nbsp;</DIV><DIV>&nbsp;</DIV><DIV><P>For reference, here's some commented code from my own from my implementation of IEntityLoginManager.Login() that spells it all out:</P><DIV><FONT color=#008000 size=2><FONT color=#008000 size=2><FONT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public IPrincipal Login(ILoginCredential pCredential, EntityManager pManager) {<BR></FONT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // pManager is a server-side EntityManager and is authorized to access the <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // back-end data stores without authentication. However, it contains none of the<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // convenient EntityQuery&lt;T&gt; properties -- e.g., em.Users -- that are included<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // with its specialized offspring, the DomainModelEntityManager.&nbsp; Therefore<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // to use it to retrieve data, you must go through its ExecuteQuery() methods:</FONT></FONT></DIV><DIV><FONT color=#008000 size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp;&nbsp;&nbsp; </FONT></DIV><DIV><FONT color=#008000 size=2><FONT color=#008000 size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp;&nbsp;&nbsp; pManager.ExecuteQuery&lt;User&gt;(new EntityQuery&lt;User&gt;().Where(u =&gt; u.UserName == pUserName));</FONT></FONT></DIV><DIV><FONT color=#008000 size=2><FONT color=#008000 size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp;&nbsp;&nbsp;&nbsp;</FONT></FONT></DIV><DIV><FONT color=#008000 size=2><FONT color=#008000 size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Alternatively, you can get a specialized DomainModelEntityManager for use, <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // but you must obtain it as follows:</FONT></FONT></DIV><DIV><FONT color=#008000 size=2></FONT>&nbsp;</DIV><DIV><FONT size=2><FONT size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DomainModelEntityManager manager = new DomainModelEntityManager(pManager);</FONT></FONT></DIV><DIV><FONT color=#008000 size=2></FONT>&nbsp;</DIV><DIV><FONT color=#008000 size=2><FONT color=#008000 size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Creating your new EntityManager using the credentials of the existing<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // server-side one results in another server-side EntityManager. It therefore also<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // permits access to the backend datastore without authentication. As a bonus, it also <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // excludes the client-server communications overhead that a client-side <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // EntityManager normally carries.</FONT></FONT></DIV><DIV><FONT color=#008000 size=2><FONT color=#008000 size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp;&nbsp;&nbsp;&nbsp;</FONT></FONT></DIV><DIV><FONT color=#008000 size=2><FONT color=#008000 size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Two things that don't work:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // 1. Direct casting of the passed-in EntityManager:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp;&nbsp;&nbsp; DomainModelEntityManager manager = (DomainModelEntityManager)pManager;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // 2. Creation of a new DomainModelEntityManager using the parameterless constructor:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp;&nbsp;&nbsp; DomainModelEntityManager manager = new DomainModelEntityManager();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // In the first case, the cast simply fails. In the second, you get a normal (client-side) <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // DomainModelEntityManager that doesn't permit data retrieval from the back-end<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // data sources without authentication.</FONT></FONT></DIV><DIV><FONT color=#008000 size=2><FONT color=#008000 size=2></FONT></FONT>&nbsp;</DIV><DIV><FONT color=#008000 size=2><FONT color=#008000 size=2></FONT></FONT>&nbsp;</DIV><DIV><FONT size=2><FONT size=2>Regards,</FONT></FONT></DIV><DIV><FONT size=2><FONT size=2>Greg</FONT></FONT></DIV><DIV><FONT color=#008000 size=2><FONT color=#008000 size=2>&nbsp;</DIV></DIV></FONT></FONT>]]>
   </description>
   <pubDate>Mon, 01 Dec 2008 15:06:16 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1009&amp;PID=3667#3667</guid>
  </item> 
  <item>
   <title>Login Exception with IEntityLoginManager : I&amp;#039;m writing some unit tests...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1009&amp;PID=3659#3659</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=399" rel="nofollow">LesleySastro</a><br /><strong>Subject:</strong> 1009<br /><strong>Posted:</strong> 28-Nov-2008 at 1:14pm<br /><br /><P>I'm writing some unit tests to test my domain model. When testing the login procedure I am getting the following exception </P><DIV><strong>IdeaBlade.EntityModel.v4.LoginException: Failed to login before using EntityManager or submitted null credentials..</strong></DIV><DIV>&nbsp;</DIV><DIV>I don't know what is causing this problem, because I don't have null credentials. This exception is thrown when in the Login method of my IEntityLoginManager derived class, I am trying to get the user from the backend and compare the username and password of the User entity with the given credentials. At this point the EntityManager is not logged in, because that is what I'm trying to do with this method. BTW, I used to do this in DevForce Classic with no problems.</DIV><DIV>&nbsp;</DIV><DIV>Did anyone encounter the same problem and know what the fix is?</DIV>]]>
   </description>
   <pubDate>Fri, 28 Nov 2008 13:14:43 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1009&amp;PID=3659#3659</guid>
  </item> 
 </channel>
</rss>