<?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 : Generic Identity Authorisation in 2-tier</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2010 : Generic Identity Authorisation in 2-tier</description>
  <pubDate>Sun, 28 Jun 2026 08:51:46 -700</pubDate>
  <lastBuildDate>Mon, 27 Jun 2011 11:54:38 -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=2780</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>Generic Identity Authorisation in 2-tier : Hi John;Actually, I was running...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2780&amp;PID=11116#11116</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=912" rel="nofollow">DenisK</a><br /><strong>Subject:</strong> 2780<br /><strong>Posted:</strong> 27-Jun-2011 at 11:54am<br /><br />Hi John;<div><br></div><div>Actually, I was running this from the debugger. I think this is just a matter of setting the right options on Debug -&gt; Exceptions on your VS2010.</div>]]>
   </description>
   <pubDate>Mon, 27 Jun 2011 11:54:38 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2780&amp;PID=11116#11116</guid>
  </item> 
  <item>
   <title>Generic Identity Authorisation in 2-tier : Hi Denis,I see where I was going...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2780&amp;PID=11106#11106</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1181" rel="nofollow">jradxl</a><br /><strong>Subject:</strong> 2780<br /><strong>Posted:</strong> 24-Jun-2011 at 3:43pm<br /><br />Hi Denis,<br><br>I see where I was going wrong. I was running in the VS2010 debugger, and it stopped at the throw line.<br>If I run Console01.exe from the bin\Debug directory, it works.<br><br>I added two more Console.WriteLine statements, and it does get back to the Client, as shown.<br><br>Thread principal before login:<br>Non-Windows Login<br>About to Throw on Server...<br>In Client Catch<br>LoginException: 'johnx' is not a user name in the 'domain' domain.<br>Press ENTER to exit...<br><br>I was expecting the Debuger to find the Catch statement in the Client.<br>Sorry. I assume you were running the exe directory?<br><br>rgds<br>John<br><br>]]>
   </description>
   <pubDate>Fri, 24 Jun 2011 15:43:04 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2780&amp;PID=11106#11106</guid>
  </item> 
  <item>
   <title>Generic Identity Authorisation in 2-tier :  Hi John;I tried version 6.1.0...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2780&amp;PID=11104#11104</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=912" rel="nofollow">DenisK</a><br /><strong>Subject:</strong> 2780<br /><strong>Posted:</strong> 24-Jun-2011 at 2:29pm<br /><br /><div>Hi John;</div><div><br></div><div>I tried version 6.1.0 and 6.1.1. However, I don't think it has anything to do with the version. I do hope though that I'm not misunderstanding your question.</div><div><br></div><div>To clarify, you want a LoginException thrown on the server and caught on the client. In my code sample, I have the following:</div><div><br></div><div><b>CLIENT</b></div><div><br></div><div><table width="99%"><tr><td><pre class="BBcode"></div><div><div>&nbsp; &nbsp; &nbsp; try {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; // Login will null credentials. &nbsp;The LoginManager will decide what to do ...</div><div>&nbsp; &nbsp; &nbsp; &nbsp; //loginResult = mgr.Login((ILoginCredential)null);</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; LoginCredential cred = new LoginCredential("johnxxx", "password", "domain");</div><div>&nbsp; &nbsp; &nbsp; &nbsp; var loginResult = mgr.Login((ILoginCredential)cred);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; var isLoggedIn = mgr.IsLoggedIn;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; Console.WriteLine("Thread principal after login: {0}", System.Threading.Thread.CurrentPrincipal.Identity.Name);</div><div>&nbsp; &nbsp; &nbsp; } catch (LoginException le) {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; Console.WriteLine("LoginException: " + le.Message);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; var isLoggedIn = mgr.IsLoggedIn;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; Console.WriteLine("Press ENTER to exit...");</div><div>&nbsp; &nbsp; &nbsp; &nbsp; Console.ReadLine();</div><div>&nbsp; &nbsp; &nbsp; &nbsp; return;</div><div>&nbsp; &nbsp; &nbsp; }</div></div><div></pre></td></tr></table></div><div><br></div><div><b>SERVER</b></div><div><br></div><div><table width="99%"><tr><td><pre class="BBcode"></div><div><div>&nbsp; &nbsp; public IPrincipal Login(ILoginCredential credential, EntityManager entityManager) {</div><div><br></div><div>&nbsp; &nbsp; &nbsp; if (credential == null) {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; #region If Credential is null</div><div>&nbsp; &nbsp; &nbsp; &nbsp; //details omitted</div><div>&nbsp; &nbsp; &nbsp; &nbsp; #endregion</div><div>&nbsp; &nbsp; &nbsp; } else {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; Console.WriteLine("Non-Windows Login");</div><div>&nbsp; &nbsp; &nbsp; &nbsp; GenericIdentity gi = null;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; if (credential.UserName.Equals("john")) { //change to somthing else to force failure</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; gi = new GenericIdentity(credential.UserName, "MyAuthoType");</div><div>&nbsp; &nbsp; &nbsp; &nbsp; } else {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; throw new LoginException(LoginExceptionType.InvalidUserName, credential.Domain, credential.UserName);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; &nbsp; &nbsp; GenericPrincipal gp = new GenericPrincipal(gi, null);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; Console.WriteLine("Non-Windows Login Completed.");</div><div>&nbsp; &nbsp; &nbsp; &nbsp; return CreateUser(gp);</div><div>&nbsp; &nbsp; &nbsp; }</div><div><br></div><div>&nbsp; &nbsp; &nbsp; //throw new NotImplementedException("Only Windows authentication is supported here");</div><div>&nbsp; &nbsp; }</div></div><div></pre></td></tr></table></div><div><br></div><div><b>CONSOLE OUTPUT</b></div><div><br></div><table width="99%"><tr><td class="BBquote"><div><div>Thread principal before login:</div><div>Non-Windows Login</div><div>LoginException: 'johnxxx' is not a user name in the 'domain' domain.</div><div>Press ENTER to exit...</div></div><div></td></tr></table></div><div><br></div><div>Is this not what you're seeing and/or expecting?</div><div><br></div><div>I've attached my debug log here.&nbsp;<a href="uploads/912/Debug.zip" target="_blank">uploads/912/Debug.zip</a></div>]]>
   </description>
   <pubDate>Fri, 24 Jun 2011 14:29:11 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2780&amp;PID=11104#11104</guid>
  </item> 
  <item>
   <title>Generic Identity Authorisation in 2-tier : Hello Denis,Thanks for code sample....</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2780&amp;PID=11097#11097</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1181" rel="nofollow">jradxl</a><br /><strong>Subject:</strong> 2780<br /><strong>Posted:</strong> 24-Jun-2011 at 1:26am<br /><br />Hello Denis,<br>Thanks for code sample. Unfortunately it runs with same issue on my laptop - throws in LoginManager on the Server.<br>I've upgraded to 6.1.1 from 6.1.0. No change.<br><br>What version of DF did you compile and run against? Please attach copy of your DebugLog after a failed login.<br><br>thanks<br>John<br><br>]]>
   </description>
   <pubDate>Fri, 24 Jun 2011 01:26:36 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2780&amp;PID=11097#11097</guid>
  </item> 
  <item>
   <title>Generic Identity Authorisation in 2-tier : Hi John;Hmm, that&amp;#039;s strange....</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2780&amp;PID=11090#11090</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=912" rel="nofollow">DenisK</a><br /><strong>Subject:</strong> 2780<br /><strong>Posted:</strong> 23-Jun-2011 at 4:25pm<br /><br />Hi John;<div><br></div><div>Hmm, that's strange. Here's my sample solution that shows that LoginException is caught on the client.</div><div><br></div><div><a href="http://www.ideablade.com/friends/C&#111;nsole_SecurityWindowsAuthenticati&#111;n.zip" target="_blank">www.ideablade.com/friends/Console_SecurityWindowsAuthentication.zip</a></div><div><br></div><div>Hopefully you'll be able to see the difference. If not, feel free to upload your solution to me and I'll see what I can do.</div>]]>
   </description>
   <pubDate>Thu, 23 Jun 2011 16:25:39 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2780&amp;PID=11090#11090</guid>
  </item> 
  <item>
   <title>Generic Identity Authorisation in 2-tier :  Hello DenisK,Thank you for your...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2780&amp;PID=11083#11083</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1181" rel="nofollow">jradxl</a><br /><strong>Subject:</strong> 2780<br /><strong>Posted:</strong> 23-Jun-2011 at 11:44am<br /><br />Hello DenisK,<br>Thank you for your time in search back to my question.<br><br>I'm sorry, but I do not find,<br><span style="-webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px;"><pre ="bbcode"=""><span style="-webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px;">throw new LoginException(LoginExceptionType.InvalidUserName, credential.Domain, credential.UserName);<br></span></pre></span>returning to the Client,<br>as this DebugLog file below shows. The application stops dead at the throw statement.<br><br>I guess that calling Login is early in your library's initialisation, and the method for returning to the Client is not available.<br><br>thanks<br>John<br><br><font size="1">&lt;?xml version="1.0"?&gt;&lt;?xml-stylesheet href="DebugLog.xsl" type="text/xsl"?&gt;<br>&lt;log&gt;<br>&lt;entry id="14" timestamp="2011-06-23T19:36:20" username="" source="IdeaBlade.Core.TraceFileXmlLogger:GetLogHeader"&gt;------------ Log Created ------------&lt;/entry&gt;<br>&lt;entry id="0" timestamp="2011-06-23T19:36:15" username="" source="Console01.Program:DoIt"&gt;TraceFns: Program Starting...&lt;/entry&gt;<br>&lt;entry id="1" timestamp="2011-06-23T19:36:15" username="" source="Console01.Program:DoIt"&gt;DebugFns: Program Starting...&lt;/entry&gt;<br>&lt;entry id="2" timestamp="2011-06-23T19:36:15" username="" source="IdeaBlade.Core.IdeaBladeConfig:Initialize"&gt;Initializing configuration ...&lt;/entry&gt;<br>&lt;entry id="3" timestamp="2011-06-23T19:36:17" username="" source="IdeaBlade.Core.Composition.PartsCatalog:LoadCatalog"&gt;MEF assembly probing started: 23/06/2011 19:36:17.&nbsp; If this takes a long time, use IdeaBlade.Core.Composition.CompositionHost to specify/restrict which assemblies to probe.&lt;/entry&gt;<br>&lt;entry id="4" timestamp="2011-06-23T19:36:17" username="" source="IdeaBlade.Core.Composition.PartsCatalog:LoadCatalog"&gt;Assembly 'Console01, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' added to PartsCatalog&lt;/entry&gt;<br>&lt;entry id="5" timestamp="2011-06-23T19:36:17" username="" source="IdeaBlade.Core.Composition.PartsCatalog:LoadCatalog"&gt;Error loading assembly 'C:\VSProjects\VS2010\DevForce\Console_SecurityWindowsAuthentication\080_Secure\Console_SecurityWindowsAuthentication-2TierNoServer\CodeCS\Console01\bin\Debug\Console01.exe.config' for PartsCatalog: Error with file Console01.exe.config.&lt;/entry&gt;<br>&lt;entry id="6" timestamp="2011-06-23T19:36:17" username="" source="IdeaBlade.Core.Composition.PartsCatalog:LoadCatalog"&gt;MEF assembly probing completed: 23/06/2011 19:36:17&lt;/entry&gt;<br>&lt;entry id="7" timestamp="2011-06-23T19:36:17" username="" source="IdeaBlade.Core.Composition.CompositionHost:.ctor"&gt;Probe Assemblies: Console01, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null :: SimpleNorthwindModel.Desktop, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null :: WPFTraceViewer, Version=6.1.0.0, Culture=neutral, PublicKeyToken=287b5094865421c0&nbsp; If this list is unnecessarily large, use CompositionHost.SearchPatterns to modify the search critieria for probed assemblies. If this list does not contain the assembly(ies) holding your a) domain model, b) custom interface implementations, and c) POCO/known types then your application may not work correctly. Ensure that these assemblies are available in the exe/bin folder, and if using CompositionHost.SearchPatterns that the patterns are set appropriately.&lt;/entry&gt;<br>&lt;entry id="8" timestamp="2011-06-23T19:36:17" username="" source="IdeaBlade.Core.IdeaBladeConfig:InitializationStatusCallback"&gt;IdeaBlade License: 'EnterpriseUniv, Express', KeyDate: 15/04/2010, AllowedSessions: 10000. Found on Assembly: 'SimpleNorthwindModel.Desktop, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'&lt;/entry&gt;<br>&lt;entry id="9" timestamp="2011-06-23T19:36:17" username="" source="IdeaBlade.Core.Configuration.ServerSettingsElement:ConstrainSettingsBasedOnLicenseCore"&gt;The configured SupportedClientApplicationType is Both&lt;/entry&gt;<br>&lt;entry id="10" timestamp="2011-06-23T19:36:17" username="" source="IdeaBlade.Core.Configuration.ServerSettingsElement:ConstrainSettingsBasedOnLicenseCore"&gt;Could not find a valid license to enable session-agnostic load balancing.&lt;/entry&gt;<br>&lt;entry id="11" timestamp="2011-06-23T19:36:20" username="" source="IdeaBlade.Core.Configuration.ServerSettingsElement:ConstrainSettingsBasedOnLicenseCore"&gt;Could not find a valid license to enable session-agnostic load balancing.&lt;/entry&gt;<br>&lt;/log&gt;<br></font><br>]]>
   </description>
   <pubDate>Thu, 23 Jun 2011 11:44:57 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2780&amp;PID=11083#11083</guid>
  </item> 
  <item>
   <title>Generic Identity Authorisation in 2-tier : Hi jradxl; I&amp;#039;d much prefer...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2780&amp;PID=11077#11077</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=912" rel="nofollow">DenisK</a><br /><strong>Subject:</strong> 2780<br /><strong>Posted:</strong> 22-Jun-2011 at 5:03pm<br /><br />Hi jradxl;<div><br></div><div><table width="99%"><tr><td class="BBquote"></div><div><span ="Apple-style-span" style="-webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px; ">I'd much prefer to have&nbsp;<span style="color: green; ">LoginExceptionType.InvalidUserName</span>&nbsp;returned to the Client.<br>Please can you suggest a way?</span></div><div><span ="Apple-style-span" style="-webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px; "></td></tr></table></span></div><div><span ="Apple-style-span" style="-webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px; "><br></span></div><div><span ="Apple-style-span" style="-webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px;">To do this, you can throw a LoginException back to the client.</span></div><div><span ="Apple-style-span" style="-webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px;"><br></span></div><div><span ="Apple-style-span" style="-webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px;"><table width="99%"><tr><td><pre class="BBcode"></span></div><div><span ="Apple-style-span" style="-webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px;">throw new LoginException(LoginExceptionType.InvalidUserName, credential.Domain, credential.UserName);</span></div><div><span ="Apple-style-span" style="-webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px;"></pre></td></tr></table></span></div><div><span ="Apple-style-span" style="-webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px;"><br></span></div><div><span ="Apple-style-span" style="-webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px;">I see that you commented that part of the code out and you create a GenericIdentity instead with IsAuthenticated = false. A login and authentication are 2 different processes. A user can successfully login but not authenticated. To disallow login, a LoginException needs to be thrown.</span></div><div><span ="Apple-style-span" style="-webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px;"><br></span></div><div><span ="Apple-style-span" style="-webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px;"><table width="99%"><tr><td class="BBquote"></span></div><div><span ="Apple-style-span" style="-webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px; ">Alternatively, can you support:-<br><pre style="font-family: C&#111;nsolas; color: black; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var loginResult&nbsp;=&nbsp;mgr.Login((<span style="color: rgb43, 145, 175; ">ILoginCredential</span>)cred);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var isLoggedIn&nbsp;=&nbsp;mgr.IsLoggedIn;<br><br>as false, when the login fails. So that one can test in the Client, and not have an exception.</pre></span><span ="Apple-style-span" style="-webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px; "></td></tr></table></span></div><div><span ="Apple-style-span" style="-webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px; "><br></span></div><div><span ="Apple-style-span" style="-webkit-border-horiz&#111;ntal-spacing: 1px; -webkit-border-vertical-spacing: 1px;">Currently, as I've noted above, to indicate a failed login, one has to throw a LoginException. If you have a convincing use case for this, I might be able to discuss this with a senior engineer and add it to the feature request list.</span></div>]]>
   </description>
   <pubDate>Wed, 22 Jun 2011 17:03:01 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2780&amp;PID=11077#11077</guid>
  </item> 
  <item>
   <title>Generic Identity Authorisation in 2-tier :     Generic Identity Authorisation...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2780&amp;PID=11032#11032</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1181" rel="nofollow">jradxl</a><br /><strong>Subject:</strong> 2780<br /><strong>Posted:</strong> 18-Jun-2011 at 2:43pm<br /><br />Generic Identity Authorisation in 2-tier<br><br>Hi,<br>Using your example Console_SecurityWindowsAuthentication, which I have arranged to be 2-tier, I am adding code to support non-Windows Generic Identity Authorization.<br><br>In your code example of IEntityLoginManager you have a LoginException being generated on the Server side (which is of course in 2-tier also running on the client), if the login fails.<br><br>On the otherhand, if the GenericIdenity.IsAuthenticatedis false, the login as seen by the Client still succeeds.<br><br>Also, EntityServerQueryInterceptor is probed for after the login is completed.<br><br>The only way I can find of returning a failed login back to the Client is to return a null UserBase. This causes a <span style="color:#2b91af;">EntityServerException</span> of "Session Bundle is invalid". Which matches your code example.<br>Only in the Catch blocks is EntityManager.IsLoggedInfalse.<br><br>I'd much prefer to have <span style="color:green;">LoginExceptionType.InvalidUserName</span> returned to the Client.<br>Please can you suggest a way?<br><br>Alternatively, can you support:-<br><pre style="font-family:C&#111;nsolas;font-size:13;color:black;:white;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var loginResult&nbsp;=&nbsp;mgr.Login((<span style="color:#2b91af;">ILoginCredential</span>)cred);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var isLoggedIn&nbsp;=&nbsp;mgr.IsLoggedIn;<br><br>as false, when the login fails. So that one can test in the Client, and not have an exception.<br><br>//Client<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue;">void</span>&nbsp;DoIt()&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#2b91af;">NorthwindManager</span>&nbsp;mgr&nbsp;=&nbsp;<span style="color:blue;">new</span>&nbsp;<span style="color:#2b91af;">NorthwindManager</span>(); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:green;">//IdeaBlade.Core.IdeaBladeConfig.ConfigFileAssembly&nbsp;=&nbsp;Assembly.GetExecutingAssembly();</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:blue;">var</span>&nbsp;configInstance&nbsp;=&nbsp;IdeaBlade.Core.<span style="color:#2b91af;">IdeaBladeConfig</span>.Instance;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;configInstance.ObjectServer.ClientSettings.IsDistributed&nbsp;=&nbsp;<span style="color:blue;">false</span>;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;configInstance.ObjectServer.ServerSettings.AllowAnonymousLogin&nbsp;=&nbsp;<span style="color:blue;">false</span>;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;configInstance.ObjectServer.ServerSettings.LoginManagerRequired&nbsp;=&nbsp;<span style="color:blue;">true</span>;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;configInstance.Logging.ShouldLogSqlQueries&nbsp;=&nbsp;<span style="color:blue;">true</span>;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;configInstance.Logging.LogFile&nbsp;=&nbsp;<span style="color:#a31515;">"MyLogFile.xml"</span>; //not working. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:#2b91af;">Console</span>.WriteLine(<span style="color:#a31515;">"Thread&nbsp;principal&nbsp;before&nbsp;login:&nbsp;{0}"</span>,&nbsp;System.Threading.<span style="color:#2b91af;">Thread</span>.CurrentPrincipal.Identity.Name);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:blue;">bool</span>&nbsp;isLoggedIn&nbsp;=&nbsp;<span style="color:blue;">false</span>;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:blue;">bool</span>&nbsp;loginResult&nbsp;=&nbsp;<span style="color:blue;">false</span>;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue;">try</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:green;">//&nbsp;Login&nbsp;will&nbsp;null&nbsp;credentials.&nbsp;&nbsp;The&nbsp;LoginManager&nbsp;will&nbsp;decide&nbsp;what&nbsp;to&nbsp;do&nbsp;...</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#2b91af;">LoginCredential</span>&nbsp;cred&nbsp;=&nbsp;<span style="color:blue;">new</span>&nbsp;<span style="color:#2b91af;">LoginCredential</span>(<span style="color:#a31515;">"john"</span>,&nbsp;<span style="color:#a31515;">"password"</span>,&nbsp;<span style="color:#a31515;">"domain"</span>);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:green;">//loginResult&nbsp;=&nbsp;mgr.Login((ILoginCredential)null);&nbsp;</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;loginResult&nbsp;=&nbsp;mgr.Login((<span style="color:#2b91af;">ILoginCredential</span>)cred);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;isLoggedIn&nbsp;=&nbsp;mgr.IsLoggedIn;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#2b91af;">Console</span>.WriteLine(<span style="color:#a31515;">"Thread&nbsp;principal&nbsp;after&nbsp;login:&nbsp;{0}"</span>,&nbsp;System.Threading.<span style="color:#2b91af;">Thread</span>.CurrentPrincipal.Identity.Name);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:blue;">catch</span>&nbsp;(<span style="color:#2b91af;">LoginException</span>&nbsp;le)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#2b91af;">Console</span>.WriteLine(<span style="color:#a31515;">"LoginException:&nbsp;"</span>&nbsp;+&nbsp;le.Message);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;isLoggedIn&nbsp;=&nbsp;mgr.IsLoggedIn;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#2b91af;">Console</span>.WriteLine(<span style="color:#a31515;">"Press&nbsp;ENTER&nbsp;to&nbsp;exit..."</span>);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#2b91af;">Console</span>.ReadLine();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:blue;">return</span>;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:blue;">catch</span>&nbsp;(<span style="color:#2b91af;">EntityServerException</span>&nbsp;ese)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#2b91af;">Console</span>.WriteLine(<span style="color:#a31515;">"EntityServerException&nbsp;Login&nbsp;failed:&nbsp;"</span>&nbsp;+&nbsp;ese.Message);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;isLoggedIn&nbsp;=&nbsp;mgr.IsLoggedIn;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#2b91af;">Console</span>.WriteLine(<span style="color:#a31515;">"Press&nbsp;ENTER&nbsp;to&nbsp;exit..."</span>);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#2b91af;">Console</span>.ReadLine();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:blue;">return</span>;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:blue;">catch</span>&nbsp;(<span style="color:#2b91af;">Exception</span>&nbsp;ex)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue;">bool</span>&nbsp;isLogged&nbsp;=&nbsp;mgr.IsLoggedIn;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#2b91af;">Console</span>.WriteLine(ex.Message);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:blue;">return</span>;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br><br>            // etc....<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br><br>//Server<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:blue;">public</span>&nbsp;<span style="color:#2b91af;">IPrincipal</span>&nbsp;Login(<span style="color:#2b91af;">ILoginCredential</span>&nbsp;credential,&nbsp;<span style="color:#2b91af;">EntityManager</span>&nbsp;entityManager)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:blue;">if</span>&nbsp;(credential&nbsp;==&nbsp;<span style="color:blue;">null</span>)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:green;">//&nbsp;if&nbsp;running&nbsp;n-tier&nbsp;the&nbsp;user's&nbsp;Windows&nbsp;credentials&nbsp;will&nbsp;be&nbsp;passed&nbsp;and&nbsp;available&nbsp;on&nbsp;the&nbsp;thread:</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:blue;">var</span>&nbsp;principal&nbsp;=&nbsp;System.Threading.<span style="color:#2b91af;">Thread</span>.CurrentPrincipal;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:blue;">if</span>&nbsp;(principal.Identity.IsAuthenticated)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#2b91af;">Logger</span>.WriteMsg(<span style="color:blue;">string</span>.Format(<span style="color:#a31515;">"principal&nbsp;is&nbsp;{0}"</span>,&nbsp;principal.Identity.Name));&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:green;">//&nbsp;Note&nbsp;that&nbsp;we&nbsp;can't&nbsp;return&nbsp;the&nbsp;WindowsPrincipal/WindowsIdentity&nbsp;back&nbsp;to&nbsp;the&nbsp;client,&nbsp;so</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:green;">//&nbsp;create&nbsp;a&nbsp;new&nbsp;one,&nbsp;here&nbsp;we&nbsp;use&nbsp;the&nbsp;DevForce&nbsp;UserBase&nbsp;class,&nbsp;but&nbsp;you&nbsp;can&nbsp;create&nbsp;your&nbsp;own&nbsp;too.&nbsp;</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:blue;">return</span>&nbsp;CreateUser(principal);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:blue;">else</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:green;">//&nbsp;This&nbsp;is&nbsp;here&nbsp;for&nbsp;2-tier&nbsp;testing,&nbsp;since&nbsp;you'll&nbsp;probably&nbsp;want&nbsp;to&nbsp;throw&nbsp;an&nbsp;error&nbsp;or&nbsp;do</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:green;">//&nbsp;some&nbsp;custom&nbsp;logic&nbsp;in&nbsp;n-tier.&nbsp;&nbsp;When&nbsp;not&nbsp;running&nbsp;n-tier,&nbsp;the&nbsp;thread&nbsp;principal&nbsp;has&nbsp;not&nbsp;been&nbsp;set&nbsp;</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:green;">//&nbsp;but&nbsp;you&nbsp;can&nbsp;obtain&nbsp;the&nbsp;Windows&nbsp;Identity&nbsp;and&nbsp;use&nbsp;that.</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:blue;">var</span>&nbsp;wi&nbsp;=&nbsp;<span style="color:#2b91af;">WindowsIdentity</span>.GetCurrent();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#2b91af;">Logger</span>.WriteMsg(<span style="color:blue;">string</span>.Format(<span style="color:#a31515;">"wi&nbsp;is&nbsp;{0}"</span>,&nbsp;wi.Name));&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#2b91af;">WindowsPrincipal</span>&nbsp;wp&nbsp;=&nbsp;<span style="color:blue;">new</span>&nbsp;<span style="color:#2b91af;">WindowsPrincipal</span>(wi);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:blue;">return</span>&nbsp;CreateUser(wp);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:blue;">else</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#2b91af;">Logger</span>.WriteMsg(<span style="color:#a31515;">"Non-Windows&nbsp;Login"</span>);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#2b91af;">GenericIdentity</span>&nbsp;gi&nbsp;=&nbsp;<span style="color:blue;">null</span>;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:blue;">if</span>&nbsp;(credential.UserName.Equals(<span style="color:#a31515;">"john"</span>)) //change to somthing else to force failure&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gi&nbsp;=&nbsp;<span style="color:blue;">new</span>&nbsp;<span style="color:#2b91af;">GenericIdentity</span>(credential.UserName,&nbsp;<span style="color:#a31515;">"MyAuthoType"</span>);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:blue;">else</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>                    //This is the way of getting IsAuthenticated set to false&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gi&nbsp;=&nbsp;<span style="color:blue;">new</span>&nbsp;<span style="color:#2b91af;">GenericIdentity</span>(<span style="color:#a31515;">""</span>,&nbsp;<span style="color:#a31515;">"MyAuthoType"</span>); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:green;">//This&nbsp;will&nbsp;throw&nbsp;in&nbsp;EntityServer</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:green;">//&nbsp;throw&nbsp;new&nbsp;LoginException(LoginExceptionType.InvalidUserName,&nbsp;credential.Domain,&nbsp;credential.UserName);</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#2b91af;">GenericPrincipal</span>&nbsp;gp&nbsp;=&nbsp;<span style="color:blue;">new</span>&nbsp;<span style="color:#2b91af;">GenericPrincipal</span>(gi,&nbsp;<span style="color:blue;">null</span>);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#2b91af;">Logger</span>.WriteMsg(<span style="color:#a31515;">"Non-Windows&nbsp;Login&nbsp;Completed."</span>);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:blue;">return</span>&nbsp;CreateUser(gp);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:blue;">throw</span>&nbsp;<span style="color:blue;">new</span>&nbsp;<span style="color:#2b91af;">NotImplementedException</span>(<span style="color:#a31515;">"Some&nbsp;Login&nbsp;Error"</span>);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:blue;">private</span>&nbsp;<span style="color:#2b91af;">UserBase</span>&nbsp;CreateUser(<span style="color:#2b91af;">IPrincipal</span>&nbsp;currentUser)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:green;">//&nbsp;The&nbsp;UserBase&nbsp;and&nbsp;UserIdentity&nbsp;classes&nbsp;are&nbsp;custom&nbsp;IPrincipal/IIdentity&nbsp;implementations</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:green;">//&nbsp;within&nbsp;DevForce.&nbsp;&nbsp;</span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#2b91af;">UserIdentity</span>&nbsp;identity&nbsp;=&nbsp;<span style="color:blue;">new</span>&nbsp;<span style="color:#2b91af;">UserIdentity</span>(currentUser.Identity.Name,&nbsp;currentUser.Identity.AuthenticationType,&nbsp;currentUser.Identity.IsAuthenticated);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:blue;">bool</span>&nbsp;isInRole&nbsp;=&nbsp;currentUser.IsInRole(<span style="color:#a31515;">""</span>);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:blue;">var</span>&nbsp;isAuth&nbsp;=&nbsp;currentUser.Identity.IsAuthenticated; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:green;">//&nbsp;You&nbsp;can&nbsp;determine&nbsp;what&nbsp;roles&nbsp;to&nbsp;set,&nbsp;if&nbsp;any.</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:blue;">string</span>&#091;&#093;&nbsp;roles&nbsp;=&nbsp;<span style="color:blue;">new</span>&nbsp;<span style="color:blue;">string</span>&#091;&#093;&nbsp;{&nbsp;}; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:blue;">if</span>&nbsp;(isAuth)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#2b91af;">Logger</span>.WriteMsg(<span style="color:#a31515;">"UserBase&nbsp;created."</span>);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:blue;">return</span>&nbsp;<span style="color:blue;">new</span>&nbsp;<span style="color:#2b91af;">UserBase</span>(identity,&nbsp;roles);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:green;">//Will&nbsp;result&nbsp;in&nbsp;an EntityServerException in the Client</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:#2b91af;">Logger</span>.WriteMsg(<span style="color:#a31515;">"Null&nbsp;UserBase&nbsp;returned."</span>);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:blue;">return</span>&nbsp;<span style="color:blue;">null</span>;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br><br>thanks<br>John<br><br></pre><span style="color:#2b91af;"></span><span style="font-size:10px"><br /><br />Edited by jradxl - 18-Jun-2011 at 3:12pm</span>]]>
   </description>
   <pubDate>Sat, 18 Jun 2011 14:43:51 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2780&amp;PID=11032#11032</guid>
  </item> 
 </channel>
</rss>