<?xml version='1.0' encoding='utf-8' ?>
<!--  If you are running a bot please visit this policy page outlining rules you must respect. http://www.livejournal.com/bots/  -->
<rss version='2.0' xmlns:lj='http://www.livejournal.org/rss/lj/1.0/' xmlns:media='http://search.yahoo.com/mrss/' xmlns:atom10='http://www.w3.org/2005/Atom'>
<channel>
  <title>TechOnly</title>
  <link>http://techonly.livejournal.com/</link>
  <description>TechOnly - LiveJournal.com</description>
  <lastBuildDate>Sat, 28 Jul 2007 16:53:52 GMT</lastBuildDate>
  <generator>LiveJournal / LiveJournal.com</generator>
  <lj:journal>techonly</lj:journal>
  <lj:journalid>10486176</lj:journalid>
  <lj:journaltype>personal</lj:journaltype>
  <atom10:link rel='hub' href='http://pubsubhubbub.appspot.com/' />
<item>
  <guid isPermaLink='true'>http://techonly.livejournal.com/17511.html</guid>
  <pubDate>Sat, 28 Jul 2007 16:53:52 GMT</pubDate>
  <title>svchost.exe WORM_BACTERA.I</title>
  <link>http://techonly.livejournal.com/17511.html</link>
  <description>&lt;a href=&quot;http://www.trendmicro.com/vinfo/virusencyclo/default5.asp?VName=WORM_BACTERA.I&quot;&gt;http://www.trendmicro.com/vinfo/virusencyclo/default5.asp?VName=WORM_BACTERA.I&lt;/a&gt;</description>
  <comments>http://techonly.livejournal.com/17511.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>3</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://techonly.livejournal.com/17397.html</guid>
  <pubDate>Mon, 23 Jul 2007 05:52:48 GMT</pubDate>
  <title>advice from xupeng</title>
  <link>http://techonly.livejournal.com/17397.html</link>
  <description>用COOIKE试一下，就是在一个单点登陆的地方下一个COOIKE，然后另外两个系统检测这个COOIKE. 注意把COOIKE加密&lt;br /&gt;&lt;br /&gt;必须让用户都读写一个表&lt;br /&gt;&lt;br /&gt;就是说，所以有数据库的用户信息，都要放到一个数据库的表里</description>
  <comments>http://techonly.livejournal.com/17397.html</comments>
  <category>sso</category>
  <category>website</category>
  <category>asp.net</category>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://techonly.livejournal.com/17044.html</guid>
  <pubDate>Fri, 15 Jun 2007 06:19:11 GMT</pubDate>
  <title>Linux Distribution Chooser</title>
  <link>http://techonly.livejournal.com/17044.html</link>
  <description>&lt;a href=&quot;http://www.zegeniestudios.net/ldc/index.php?lang=en&quot;&gt;http://www.zegeniestudios.net/ldc/index.php?lang=en&lt;/a&gt;</description>
  <comments>http://techonly.livejournal.com/17044.html</comments>
  <category>linux</category>
  <category>distribution</category>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://techonly.livejournal.com/16675.html</guid>
  <pubDate>Thu, 14 Jun 2007 06:54:59 GMT</pubDate>
  <title>Creating a Single Sign-on for ASP.NET Application and Legacy ASP Application (Part II)</title>
  <link>http://techonly.livejournal.com/16675.html</link>
  <description>From &lt;a href=&quot;http://www.wwwcoder.com/Directory/tabid/68/type/art/site/4922/parentid/258/Default.aspx&quot;&gt;http://www.wwwcoder.com/Directory/tabid/68/type/art/site/4922/parentid/258/Default.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;span class=&quot;rdmdesc&quot;&gt;A hack into the .NET authentication classes to extract a component that can be called by legacy asp applications to generate the same authentication token used in asp.net applications. &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span&gt;&lt;span style=&quot;FLOAT: right; WIDTH: 300px; HEIGHT: 250px; align: right&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;normal&quot;&gt;&lt;p&gt;&lt;i&gt;Ting Huang&lt;/i&gt;&lt;/p&gt;&lt;p&gt;A hack into the .NET authentication classes to extract a component that can be called by legacy asp applications to generate the same authentication token used in asp.net applications.&lt;/p&gt;&lt;p&gt;(Link to part I: &lt;u&gt;&lt;span style=&quot;FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: MS Shell Dlg&quot;&gt;&lt;a style=&quot;COLOR: blue; TEXT-DECORATION: underline&quot; href=&quot;/main/parentid/258/site/2598/68/default.aspx&quot;&gt;http://www.wwwcoder.com/main/parentid/258/site/2598/68/default.aspx&lt;/a&gt;&lt;/span&gt;&lt;/u&gt;)&lt;/p&gt;&lt;h3&gt;Introduction&lt;/h3&gt;&lt;p&gt;In part I of the article, I introduced a way to create a single sign-on between asp and asp.net applications. Although the solution is sound, it is not without shortcomings:&lt;/p&gt;&lt;p&gt;1. While the authentication token generated is different each time, it is not time-stamped. Hence, there is no expiration by itself. This could lead to a high risk of being maliciously reused when the token is hijacked.&lt;/p&gt;&lt;p&gt;2. It is not a time-saving or effort-saving solution, because additional development is required on both sides of asp and asp.net applications to manage the authentication token. &lt;/p&gt;&lt;p&gt;It would be ideal if the forms authentication mechanism from ASP.NET can be utilized by ASP application to generate or verify authentication token efficiently. Additionally, the token generated should be automatically recognized as a valid token by ASP.NET built-in forms authentication mechanism as well.&lt;/p&gt;&lt;p&gt;Inspired by a Microsoft knowledge-base article at &lt;a style=&quot;COLOR: blue; TEXT-DECORATION: underline&quot; href=&quot;http://support.microsoft.com/default.aspx?scid=kb;EN-US;891028&quot;&gt;http://support.microsoft.com/default.aspx?scid=kb;EN-US;891028&lt;/a&gt; which makes a web service to provide authentication methods for ASP application, I got the idea of using the asp.net FormsAuthentication utilities directly in classic asp. To circumvent the initialization problem, I extracted the core functionalities apart from the FormsAuthentication utilities and removed the requirements for HttpContext and other related classes that are only available in asp.net. The asp scripts will be able to use simple COM interop to call into this authentication component to retrieve as well as verify tokens.&lt;/p&gt;&lt;h3&gt;How Forms Authentication Works in ASP.NET&lt;/h3&gt;&lt;p&gt;What happens behind the scene of the form authentication mechanism in ASP.NET is that when a client request goes through the http pipeline, the FormsAuthenticationModule (a HttpModule) picks up the incoming request and tries to extract authentication ticket from cookie. The process requires decryption and reading configurations via HttpContext.&lt;/p&gt;&lt;h3&gt;Solution&lt;/h3&gt;&lt;p&gt;The solution is to extract the core functionalities apart from the FormsAuthentication utilities in ASP.NET and remove the requirements for HttpContext and other related classes and make them into a authentication component that can be called by ASP application.&lt;/p&gt;&lt;p&gt;Here is how the solution looks like:&lt;/p&gt;&lt;p&gt;&lt;img height=&quot;286&quot; src=&quot;/main/portals/1/SSOII42605.jpg&quot; width=&quot;430&quot; border=&quot;0&quot;&gt;&lt;/p&gt;&lt;p&gt;The following steps show how to get the solution working.&lt;/p&gt;&lt;p&gt;&lt;b&gt;1. Synchronize the encryption and decryption key&lt;/b&gt;&lt;/p&gt;&lt;p&gt;Forms authentication in asp.net uses the &amp;lt;machineKey&amp;gt; element in machine.config or web.config for encryption and decryption authentication token:&lt;/p&gt;&lt;p&gt;&lt;font face=&quot;Courier New&quot; size=&quot;1&quot;&gt;&amp;lt;machineKey validationKey=&quot;AutoGenerate|value[,IsolateApps]&quot; decryptionKey=&quot;AutoGenerate|value[,IsolateApps] validation=&quot;SHA1|MD5|3DES&quot;/&amp;gt;&lt;/font&gt;&lt;/p&gt;&lt;p&gt;If you have run ASP.NET applications in a server farm, you probably know that the machine key has to be set with the same value on all severs in the farm. This ensures that tokens generated on one of the servers can be validated on another. For the same reason, it is necessary to synchronize the encryption and decryption key in both ASP.NET forms authentication and the custom authentication component.&lt;/p&gt;&lt;p&gt;The following link can be used to generate a machine key setting:&lt;/p&gt;&lt;p&gt;&lt;a style=&quot;COLOR: blue; TEXT-DECORATION: underline&quot; href=&quot;http://www.eggheadcafe.com/articles/GenerateMachineKey/GenerateMachineKey.aspx&quot;&gt;http://www.eggheadcafe.com/articles/GenerateMachineKey/GenerateMachineKey.aspx&lt;/a&gt;&lt;/p&gt;&lt;p&gt;The following is an example of such setting:&lt;/p&gt;&lt;p&gt;&lt;font face=&quot;Courier New&quot; size=&quot;1&quot;&gt;&amp;lt;machineKey validationKey=&apos;6C0D4C65DBD3CF60C037E0BE43D2958954DA9AAA830D902B8481DDDF962A&lt;br&gt;4E392056DE5EEEEC0061673BB413DB533D6F8C61C70AD36C9F89F99DC0B3AD292B53&apos;   &lt;br&gt;decryptionKey=&apos;7EBC8C30854618249344BAF797E1B9DD119F249D459C006D&apos;   validation=&apos;SHA1&apos;/&amp;gt;&lt;/font&gt;&lt;/p&gt;&lt;p&gt;This is the only change has to be made in ASP.NET for the single sign-on to work.&lt;/p&gt;&lt;p&gt;&lt;b&gt;2. Create a COM wrapper for authentication&lt;/b&gt;&lt;/p&gt;&lt;p&gt;This is the ‘bare bone’ class for the authentication API.&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;FONT-FAMILY: Courier New&quot;&gt;&lt;font size=&quot;1&quot;&gt;public class AuthAPI&lt;br&gt;{&lt;br&gt;public AuthAPI()&lt;br&gt;      {} &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;FONT-FAMILY: Courier New&quot;&gt;&lt;font size=&quot;1&quot;&gt;      public void Initialize()&lt;br&gt;      {&lt;br&gt;            FormsAuthentication.Initialize();&lt;br&gt;      }&lt;br&gt;       public void Initialize1(&lt;br&gt;            string cookieName,&lt;br&gt;           &lt;span style=&quot;COLOR: blue&quot;&gt; string&lt;/span&gt; cookieDomain,&lt;br&gt;            &lt;span style=&quot;COLOR: blue&quot;&gt;string&lt;/span&gt; cookiePath,&lt;br&gt;            &lt;span style=&quot;COLOR: blue&quot;&gt;bool&lt;/span&gt; slidingExpiration,&lt;br&gt;            &lt;span style=&quot;COLOR: blue&quot;&gt;int&lt;/span&gt; timeout,&lt;br&gt;            &lt;span style=&quot;COLOR: blue&quot;&gt;bool&lt;/span&gt; requireSSL&lt;br&gt;            )&lt;br&gt;      {&lt;br&gt;            FormsAuthentication.Initialize(&lt;br&gt;                  cookieName,&lt;br&gt;                  cookieDomain,&lt;br&gt;                  cookiePath,&lt;br&gt;                  slidingExpiration,&lt;br&gt;                  timeout,&lt;br&gt;                  requireSSL&lt;br&gt;                  );&lt;br&gt;      } &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;FONT-FAMILY: Courier New&quot;&gt;&lt;font size=&quot;1&quot;&gt;      &lt;span style=&quot;COLOR: blue&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;COLOR: blue&quot;&gt;void&lt;/span&gt; Initialize2(&lt;br&gt;            &lt;span style=&quot;COLOR: blue&quot;&gt;string&lt;/span&gt; cookieName,&lt;br&gt;            &lt;span style=&quot;COLOR: blue&quot;&gt;string&lt;/span&gt; cookieDomain,&lt;br&gt;            &lt;span style=&quot;COLOR: blue&quot;&gt;string&lt;/span&gt; cookiePath,&lt;br&gt;            &lt;span style=&quot;COLOR: blue&quot;&gt;bool&lt;/span&gt; slidingExpiration,&lt;br&gt;            &lt;span style=&quot;COLOR: blue&quot;&gt;string&lt;/span&gt; protection,&lt;br&gt;            &lt;span style=&quot;COLOR: blue&quot;&gt;int&lt;/span&gt; timeout,&lt;br&gt;            &lt;span style=&quot;COLOR: blue&quot;&gt;bool&lt;/span&gt; requireSSL,&lt;br&gt;            &lt;span style=&quot;COLOR: blue&quot;&gt;string&lt;/span&gt; validationKey,&lt;br&gt;            &lt;span style=&quot;COLOR: blue&quot;&gt;string&lt;/span&gt; decryptionKey,&lt;br&gt;            &lt;span style=&quot;COLOR: blue&quot;&gt;string&lt;/span&gt; validationMode&lt;br&gt;            )&lt;br&gt;      {&lt;br&gt;            FormsAuthentication.Initialize(&lt;br&gt;                  cookieName,&lt;br&gt;                  cookieDomain,&lt;br&gt;                  cookiePath,&lt;br&gt;                  slidingExpiration,&lt;br&gt;                  (FormsProtectionEnum)Enum.Parse(&lt;span style=&quot;COLOR: blue&quot;&gt;typeof&lt;/span&gt;(FormsProtectionEnum), protection, &lt;span style=&quot;COLOR: blue&quot;&gt;true&lt;/span&gt;),&lt;br&gt;                  timeout,&lt;br&gt;                  requireSSL,&lt;br&gt;                  validationKey,&lt;br&gt;                  decryptionKey,&lt;br&gt;                  (FormsCryptoValidationMode)Enum.Parse(&lt;span style=&quot;COLOR: blue&quot;&gt;typeof&lt;/span&gt;(FormsCryptoValidationMode), validationMode, &lt;span style=&quot;COLOR: blue&quot;&gt;true&lt;/span&gt;)&lt;br&gt;                  );&lt;br&gt;      }&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;FONT-FAMILY: Courier New&quot;&gt;&lt;font size=&quot;1&quot;&gt;      &lt;span style=&quot;COLOR: blue&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;COLOR: blue&quot;&gt;string&lt;/span&gt; GetAuthCookieValue(&lt;/font&gt;&lt;/span&gt;&lt;span style=&quot;COLOR: blue; FONT-FAMILY: Courier New&quot;&gt;&lt;font size=&quot;1&quot;&gt;&lt;br&gt;            string&lt;/font&gt;&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: Courier New&quot;&gt;&lt;font size=&quot;1&quot;&gt; userName,&lt;/font&gt;&lt;/span&gt;&lt;span style=&quot;COLOR: blue; FONT-FAMILY: Courier New&quot;&gt;&lt;font size=&quot;1&quot;&gt;&lt;br&gt;            bool&lt;/font&gt;&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: Courier New&quot;&gt;&lt;font size=&quot;1&quot;&gt; createPersistentCookie)&lt;br&gt;      {&lt;br&gt;            HttpCookie cookie = FormsAuthentication.GetAuthCookie(userName, createPersistentCookie);&lt;br&gt;            &lt;span style=&quot;COLOR: blue&quot;&gt;return&lt;/span&gt; cookie.Value;&lt;br&gt;      }&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;FONT-FAMILY: Courier New&quot;&gt;&lt;font size=&quot;1&quot;&gt;       &lt;span style=&quot;COLOR: blue&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;COLOR: blue&quot;&gt;bool&lt;/span&gt; IsAuthenticated(&lt;/font&gt;&lt;/span&gt;&lt;span style=&quot;COLOR: blue; FONT-FAMILY: Courier New&quot;&gt;&lt;font size=&quot;1&quot;&gt;&lt;br&gt;            string&lt;/font&gt;&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: Courier New&quot;&gt;&lt;font size=&quot;1&quot;&gt; cookieValue,&lt;/font&gt;&lt;/span&gt;&lt;span style=&quot;COLOR: blue; FONT-FAMILY: Courier New&quot;&gt;&lt;font size=&quot;1&quot;&gt;&lt;br&gt;            out&lt;/font&gt;&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: Courier New&quot;&gt;&lt;font size=&quot;1&quot;&gt; &lt;span style=&quot;COLOR: blue&quot;&gt;string&lt;/span&gt; newCookieValue,&lt;/font&gt;&lt;/span&gt;&lt;span style=&quot;COLOR: blue; FONT-FAMILY: Courier New&quot;&gt;&lt;font size=&quot;1&quot;&gt;&lt;br&gt;            out&lt;/font&gt;&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: Courier New&quot;&gt;&lt;font size=&quot;1&quot;&gt; DateTime expiration)&lt;br&gt;      {&lt;br&gt;            &lt;span style=&quot;COLOR: blue&quot;&gt;return&lt;/span&gt; FormsAuthentication.IsAuthenticated(cookieValue, &lt;span style=&quot;COLOR: blue&quot;&gt;out&lt;/span&gt; newCookieValue, out expiration);&lt;br&gt;      }&lt;br&gt;}&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;i&gt;Initialize2&lt;/i&gt; method requires validationKey, decryptionKey and validationMode as well as other parameters being passed in order for the custom FormsAuthentication to be initialized. The two other initialization methods will use the default keys in the class. To make the COM call easier, don’t use overloads in C# for the initialization methods.&lt;/p&gt;&lt;p&gt;&lt;i&gt;GetAuthCookieValue&lt;/i&gt; method works almost the same as GetAuthCookie in ASP.NET FormsAuthentication class except that it doesn’t return a HttpCookie object but rather a string value of the cookie to be written directly to client’s browser.&lt;/p&gt;&lt;p&gt;IsAuthenticated method validates the incoming cookie if it is a valid authentication cookie. If a renew action is required for the cookie on the caller, it will return value in the newCookieValue parameter, otherwise, it will be empty. The expiration DateTime value gives convenience to the caller when it performs the renew action.&lt;/p&gt;&lt;p&gt;&lt;b&gt;3. Making a new asp authentication script&lt;/b&gt;&lt;/p&gt;&lt;p&gt;To retrieve the authentication cookie:&lt;/p&gt;&lt;p&gt;&lt;font face=&quot;Courier New&quot; size=&quot;1&quot;&gt;&amp;lt;%          cookieName               =          &quot;.ASPXAUTH&quot;&lt;br&gt;            cookieDomain             =          &quot;yourdomain&quot;&lt;br&gt;            cookiePath               =          &quot;/&quot;&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font face=&quot;Courier New&quot; size=&quot;1&quot;&gt;            Set ulogin = Server.CreateObject(&quot;SingleSignon.AuthAPI&quot;)&lt;br&gt;            uLogin.Initialize1 cookieName, cookieDomain, cookiePath, 1, 20, 0&lt;br&gt;            s = uLogin.GetAuthCookieValue(cookieName, false)&lt;br&gt;            Call AddCookie ( cookieName, s )&lt;br&gt;            set ulogin = nothing&lt;br&gt;%&amp;gt;&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font face=&quot;Courier New&quot; size=&quot;1&quot;&gt;&amp;lt;%      Set ulogin = Server.CreateObject(&quot;SingleSignon.AuthAPI&quot;)&lt;br&gt;            isLogin =  uLogin.IsAuthenticated(GetCookie(uLogin.FormsCookieName, &quot;&quot;), newCookieValue, expiration)&lt;br&gt;            If not isLogin then&lt;br&gt;                        ‘ user is not logged in, redirect to login page&lt;br&gt;            Else&lt;br&gt;                        ‘ user is logged in &lt;br&gt;                        If not isempty(newCookieValue) then&lt;br&gt;                        &apos;renew cookie&lt;br&gt;                                Call AddCookie ( cookieName, newCookieValue, expiration )&lt;br&gt;                        End If&lt;br&gt;            End If&lt;br&gt;            Set ulogin = nothing&lt;br&gt;%&amp;gt;&lt;/font&gt;&lt;/p&gt;&lt;h3&gt;Conclusion&lt;/h3&gt;&lt;p&gt;In this article, a custom authentication component is extracted from the ASP.NET forms authentication utilities to remove any HttpContext initialization so that it can be called directly in classic ASP scripts through COM interface. The authentication token obtained via this API component works between ASP.NET and ASP application, with minimum setting in ASP.NET’s forms authentication. It also works efficiently without a web service workaround.&lt;/p&gt;&lt;p&gt;There are more that can be done based on this solution. These include:&lt;/p&gt;&lt;ol style=&quot;MARGIN-TOP: 0in; MARGIN-BOTTOM: 0in&quot; type=&quot;1&quot;&gt;&lt;li class=&quot;MsoNormal&quot;&gt;Update the Authentication API to read configurations from ASP.NET application. This can either be done via web service or direct access to the config file in ASP.NET. The advantage is to avoid explicitly passing encryption keys; &lt;li class=&quot;MsoNormal&quot;&gt;Use Session or any other available solutions to maintain the state, so that calling the Authentication API for every authentication request in ASP can be avoided. &lt;/li&gt;&lt;/ol&gt;&lt;h3&gt;References&lt;/h3&gt;&lt;p&gt;For more information, please see the following resources:&lt;br&gt;ASP.NET security overview (&lt;a style=&quot;COLOR: blue; TEXT-DECORATION: underline&quot; href=&quot;http://support.microsoft.com/default.aspx?scid=kb;EN-US;891028&quot;&gt;http://support.microsoft.com/default.aspx?scid=kb;EN-US;891028&lt;/a&gt; )&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;a href=&quot;/main/portals/1/SSOII42605.rar&quot;&gt;Download the code!&lt;/a&gt;&lt;/b&gt;&lt;/p&gt;&lt;/span&gt;</description>
  <comments>http://techonly.livejournal.com/16675.html</comments>
  <category>sso</category>
  <category>asp.net</category>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://techonly.livejournal.com/16581.html</guid>
  <pubDate>Thu, 14 Jun 2007 06:53:30 GMT</pubDate>
  <title>Creating a Single Sign-on across ASP.NET Application and Legacy ASP Application</title>
  <link>http://techonly.livejournal.com/16581.html</link>
  <description>From &lt;a href=&quot;http://www.wwwcoder.com/main/parentid/258/site/2598/68/default.aspx&quot;&gt;http://www.wwwcoder.com/main/parentid/258/site/2598/68/default.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;span class=&quot;rdmdesc&quot;&gt;Encryption and hashing are used in this project to solve a common problem faced by many programmers, which is to create a single sign-on across multiple applications, which might be a mix of legacy ASP applications and ASP.NET applications. &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span&gt;&lt;span style=&quot;FLOAT: right; WIDTH: 300px; HEIGHT: 250px; align: right&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;normal&quot;&gt;&lt;b&gt;The Scenario&lt;/b&gt;&lt;/p&gt;&lt;p&gt;For many membership websites, it is a very common scenario to limit access of some services to members only and require users to login. But oftentimes these different services are served under different applications or even under different platforms. This time we want to solve the problem of making a unified login that can be shared among legacy ASP application and ASP.NET application.&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;b&gt;The First Thought&lt;/b&gt;&lt;/p&gt;&lt;p&gt;The first thought is always to try to dig out anything that can be utilized in the .NET framework. The build-in &lt;i&gt;FormsAuthentication&lt;/i&gt; class under &lt;i&gt;System.Web.Security&lt;/i&gt; namespace is the best candidate. By calling the &lt;i&gt;SetAuthCookie(string, bool)&lt;/i&gt; method in &lt;i&gt;FormsAuthentication&lt;/i&gt;, an authentication ticket for the given user identity can be created and attached to the cookie&apos;s collection of the outgoing response. Later by checking the &lt;i&gt;Request.IsAuthenticated&lt;/i&gt; value, the user&apos;s login status can be verified. This works very well among pure ASP.NET applications. But when it comes to ASP applications, these methods or objects are obviously not available, or I should say, not easy to get implemented in the same way that ASP.NET does. Since we really don¡¯t know the detail inside &lt;i&gt;FormsAuthentication&lt;/i&gt; or related classes, there is no easy way we can modify or mimic these classes to make them available to classic ASP application.&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;How about sharing these classes in GAC that can be called by ASP script? The &lt;i&gt;FormsAuthentication&lt;/i&gt; class fails when called from ASP script because it simply needs a FORM to be initialized. If the &lt;i&gt;FormsAuthentication&lt;/i&gt; and related classes can be modified, we can probably get rid of some initialization requirements that are not needed.&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;&lt;br&gt;&lt;br&gt;&lt;b&gt;The Solution&lt;/b&gt;&lt;/p&gt;&lt;p&gt;We need to make our own authentication class.&lt;br&gt;&lt;br&gt;First we create the &lt;i&gt;EncryptString&lt;/i&gt; class to serve the Obfuscation of the user&apos;s identity as well as to verify the Obfuscated string. A triple DES encryption and a couple of MD5 hashes are involved.&amp;lt;/font&amp;gt;&lt;/p&gt;&lt;pre&gt;&lt;font face=&quot;Courier New&quot; size=&quot;1&quot;&gt;using System;using System.Security.Cryptography;using System.Text;using System.Web;using System.Globalization;namespace SingleLogin{&lt;font color=&quot;#008000&quot;&gt;      /// &amp;lt;summary&amp;gt;   /// Provides a way to obfuscate the string.   /// &amp;lt;/summary&amp;gt;&lt;/font&gt;   public class EncryptString   {      public EncryptString(){}         public bool Verify(string pEncryptedString)          {            return _Verify(pEncryptedString);         }         public string EncryptedString          {            get             {               return _Encrypt();            }         }         public string UserName          {            get             {               return _UserName;            }            set            {               _UserName = value;            }        }        public string Key         {            get             {               return _Key;            }            set            {               _Key = value;            }        }        private string _Encrypt()         {           MD5CryptoServiceProvider MD5 = new MD5CryptoServiceProvider();           byte[] bKey = MD5.ComputeHash(Encoding.ASCII.GetBytes(_Key));           byte[] bUserName = MD5.ComputeHash(Encoding.ASCII.GetBytes(_UserName));           byte[] eUserName = MD5.ComputeHash(_Mix(bUserName, bKey));           TripleDESCryptoServiceProvider des = new TripleDESCryptoServiceProvider();           byte[] eKey = des.CreateEncryptor(_Key192, _IV192).TransformFinalBlock(bKey, 0, bKey.Length);           return _ByteToHexString(eUserName) + _ByteToHexString(eKey);        }        private bool _Verify(string pEncryptedString)         {            try             {               byte[] eKey = _HexToByteArray(pEncryptedString.Substring(32));               byte[] eUserName = _HexToByteArray(pEncryptedString.Substring(0, 32));               MD5CryptoServiceProvider MD5 = new MD5CryptoServiceProvider();               TripleDESCryptoServiceProvider des = new TripleDESCryptoServiceProvider();               byte[] bKey = des.CreateDecryptor(_Key192, _IV192).TransformFinalBlock(eKey, 0, eKey.Length);               byte[] bUserName = MD5.ComputeHash(Encoding.ASCII.GetBytes(_UserName));               byte[] eUserName1 = MD5.ComputeHash(_Mix(bUserName, bKey));               return (_ByteToHexString(eUserName) == _ByteToHexString(eUserName1));            }            catch (CryptographicException)             {            }            catch (FormatException)             {            }            return false;        }        private byte[] _Mix(byte[] pUserName, byte[] pKey)        {           byte[] retByteArray = new byte[pUserName.Length * 2];           int i = 0, j;           foreach(byte b in pUserName)           {              j = i * 2;              retByteArray[j] = pUserName[i];              retByteArray[j+1] = pKey[i];              i++;           }           return retByteArray;        }        private string _ByteToHexString(byte[] pByteArray)        {           string retHexString = &quot;&quot;;           foreach(byte b in pByteArray)           {              retHexString += b.ToString(&quot;x2&quot;);           }           return retHexString;        }        private static byte[] _HexToByteArray(string pHexString)        {           int length = pHexString.Length/2;           byte[] retByteArray = new byte[length];           for(int i=0; i&amp;lt; length; i++)           {              retByteArray[i] = Byte.Parse(pHexString.Substring(i*2, 2), NumberStyles.HexNumber);           }           return retByteArray;        }		        // The key used for the triple DES encryption        private readonly byte[] _Key192 = new byte[24] {           142, 216, 90, 16, 178, 40, 8, 32,           35, 167, 34, 80, 226, 200, 125, 192,           2, 94, 51, 204, 139, 35, 14, 19};		        // The Initialization Vector for the triple DES encryption        private readonly byte[] _IV192 = new byte[24] {           54, 173, 246, 179, 36, 99, 197, 3,           42, 65, 62, 38, 134, 7, 29, 123, 145,           23, 200, 58, 193, 10, 111, 232};        private string _UserName, _Key;   }}&lt;/font&gt;&lt;/pre&gt;&lt;p&gt;The process looks like the following:&lt;br&gt;&lt;/p&gt;&lt;p&gt;&lt;img src=&quot;/main/images/Creati2.gif&quot; border=&quot;0&quot;&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;The &lt;i&gt;Authentication&lt;/i&gt; class then can be created:&lt;/p&gt;&lt;pre&gt;&lt;font face=&quot;Courier New&quot; size=&quot;1&quot;&gt;using System;using System.Web;using System.Text;namespace SingleLogin{&lt;font color=&quot;#008000&quot;&gt;	    /// &amp;lt;summary&amp;gt;    /// Summary description for Authenticate.    /// &amp;lt;/summary&amp;gt;&lt;/font&gt;    public class Authentication    {       public Authentication()       {       }       public bool IsAuthenticated(string pEncString, string pUserName)       {          EncryptString sqs = new EncryptString();          sqs.UserName = pUserName;          return sqs.Verify(pEncString);       }       public string GetAuthenticateCode(string pUserName)       {          EncryptString sqs = new EncryptString();          sqs.UserName = pUserName;          sqs.Key = _GenerateRandomKey(8);          return sqs.EncryptedString;       }       private string _GenerateRandomKey(int pKeyLength)       {          Random random = new Random((int)DateTime.Now.Ticks);          int charLength = chars.Length;          StringBuilder sb = new StringBuilder();          for (int i=0; i&amp;lt; pKeyLength; i++)           {             int idx = random.Next(0, charLength);             sb.Append(chars.Substring(idx, 1));          }          return sb.ToString();       }       private const string chars = &quot;ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890&quot;;   }}&lt;/pre&gt;&lt;/font&gt;&lt;p&gt;To test our solution in ASP application, we first register our assembly with GAC. a reference can be found at  &lt;a href=&quot;http://msdn.microsoft.com/msdnmag/issues/01/08/interop/default.aspx&quot;&gt;http://msdn.microsoft.com/msdnmag/issues/01/08/interop/default.aspx&lt;/a&gt; with the part &lt;i&gt;Using .NET Objects from COM&lt;/i&gt;.&lt;br&gt;&lt;br&gt;The shortcut to register the assembly in GAC is to locate the SingleLogin.dll that can be built in our solution (see the attached solution package) and run the following two .NET commands:&lt;br&gt;regasm SingleLogin.dll&lt;br&gt;gacutil /i SingleLogin.dll&lt;/p&gt;&lt;p&gt;After that, you can run the following ASP script on the web server to test if the correct authenticated string can be generated based on the user&apos;s identity.&lt;/p&gt;&lt;pre&gt;&lt;font face=&quot;Courier New&quot;&gt;&lt;span style=&quot;BACKGROUND-COLOR: #ffff00&quot;&gt;&amp;lt;%&lt;/span&gt;   &lt;font size=&quot;1&quot;&gt;Set test = Server.CreateObject(&quot;SingleLogin.Authentication&quot;)   &lt;font color=&quot;#008000&quot;&gt;&apos; get the authenticate string&lt;/font&gt;   cookie = test.GetAuthenticateCode(&quot;demo&quot;)   response.write cookie   &lt;font color=&quot;#008000&quot;&gt;&apos; test the authenticate string with the original username&lt;/font&gt;   name = test.IsAuthenticated(cookie, &quot;demo&quot;)   response.write &quot;&amp;lt;br&amp;gt;&quot; &amp;amp; name   &lt;font color=&quot;#008000&quot;&gt;&apos; test the authenticate string with a wrong username&lt;/font&gt;   name = test.IsAuthenticated(cookie, &quot;ting&quot;)   response.write &quot;&amp;lt;br&amp;gt;&quot; &amp;amp; name   set test = nothing&lt;/font&gt;&lt;span style=&quot;BACKGROUND-COLOR: #ffff00&quot;&gt;%&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/font&gt;&lt;p&gt;A similar ASP.NET web sample is also included in the attached solution package. &lt;/p&gt;&lt;p&gt;When the applications share the same authentication methods, a single sign-on can then be created among them.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;Some Final Thoughts&lt;/b&gt;&lt;/p&gt;&lt;p&gt;There are some risks to authenticate users in the way we do. For example, the authentication cookie can be hijacked and the hijacker can reuse the cookie to authenticate himself. But this happens anyway even if you are authenticating users with the build-in &lt;i&gt;FormsAuthentication&lt;/i&gt; class. Another vulnerability is the computed key can be compromised and used to generate the authentication ticket. In this case, the attacker has to compromise the triple DES encryption.&lt;br&gt;&lt;br&gt;Still, there is plenty of space to think of for restructuring or customizing the process of encryption. Any comments are welcome here.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;References&lt;/b&gt;&lt;/p&gt;&lt;p&gt;.NET Interop: Get Ready for Microsoft .NET by Using Wrappers to Interact with COM-based Applications&lt;br&gt;&lt;a href=&quot;http://msdn.microsoft.com/msdnmag/issues/01/08/interop/default.aspx&quot;&gt;http://msdn.microsoft.com/msdnmag/issues/01/08/interop/default.aspx&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Secure Query Strings: Preventing the Tampering of Data Passed between Applications&lt;br&gt;&lt;a href=&quot;http://www.dotnetjunkies.com/how%20to/99201486-ACFD-4607-A0CC-99E75836DC72.dcik&quot;&gt;http://www.dotnetjunkies.com/how%20to/99201486-ACFD-4607-A0CC-99E75836DC72.dcik&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p class=&quot;subhead&quot;&gt;&lt;a href=&quot;/main/Portals/1/SingleLogin.zip&quot;&gt;Download the code!&lt;/a&gt;&lt;/p&gt;&lt;br&gt;&lt;b&gt;About the Author: &lt;/b&gt;&lt;br&gt;Ting Huang, a senior programmer for a fast growing Minnesota based online marketing company and spends most of his time deep in system architect, ASP.NET and SQL Server.&lt;br&gt;&lt;/span&gt;</description>
  <comments>http://techonly.livejournal.com/16581.html</comments>
  <category>sso</category>
  <category>asp.net</category>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://techonly.livejournal.com/16329.html</guid>
  <pubDate>Thu, 14 Jun 2007 06:50:15 GMT</pubDate>
  <title>ASP.NET 2.0: Implementing Single Sign On (SSO) with Membership API</title>
  <link>http://techonly.livejournal.com/16329.html</link>
  <description>From &lt;a href=&quot;http://blah.winsmarts.com/2006/05/19/aspnet-20-implementing-single-sign-on-sso-with-membership-api.aspx&quot;&gt;http://blah.winsmarts.com/2006/05/19/aspnet-20-implementing-single-sign-on-sso-with-membership-api.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The membership API is awesome. No doubt about that. But I wish it had a more obvious in-built support for SSO. The only authenticate method takes in a username and password, there is no support for a token based system. Also, if you did add another method to verify against a ticketing authority - the membership API simply ignores it.&lt;font face=&quot;Tahoma&quot; size=&quot;2&quot;&gt;&lt;br&gt;&lt;br&gt;So the question is, How to do SSO using the Membership API - custom provider or otherwise.&lt;/font&gt; &lt;p&gt;&lt;font face=&quot;Tahoma&quot; size=&quot;2&quot;&gt;Now ASP.NET has 3 kinds of authentication - &lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font face=&quot;Tahoma&quot; size=&quot;2&quot;&gt;Passport - nobody uses it anymore, and that is SSO by definition anyway.&lt;br&gt;Windows - SSO is like a moot point here.&lt;br&gt;Forms - This is where the problem begins. So thats all I&apos;m gonna discuss here.&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font face=&quot;Tahoma&quot; size=&quot;2&quot;&gt;Well, single sign on is almost always implemented using a central ticketing authority. The idea being similar to the concept of visiting a bar. You get a &quot;token&quot; stamped on the back of your hand as you walk into the bar, and then everywhere in the bar, you are recognized as &quot;over 21&quot;. &lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font face=&quot;Tahoma&quot; size=&quot;2&quot;&gt;Similarly, in a ticketing based SSO implementation, a central ticketing authority issues you a &quot;ticket&quot; at logon. Then you can integrate with any other system by passing the &quot;ticket&quot;, rather than your authentication credentials. Then as long as the protected system can verify the &quot;ticket&quot; as being valid, you&apos;re in. Else, you&apos;re out.&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font face=&quot;Tahoma&quot; size=&quot;2&quot;&gt;Anyway, so the first thing you need to do is &lt;strong&gt;setup a ticket verification webservice&lt;/strong&gt;. The idea being, anytime you successfully authenticate, you will be issued a ticket, which will ideally be a GUID, stored as cookie that expires when the user hits the CROSS button on his browser. Then you can circumvent the membership API&apos;s &quot;Authenticate&quot; method, by instead verifying the ticket - IF one is present. &lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font face=&quot;Tahoma&quot; size=&quot;2&quot;&gt;So lets assume that the ticket is being passed as a querystring called &quot;ssoToken&quot;. Obviously, &lt;strong&gt;if someone else sniffed your ticketID, then he could masquerade as you - so this approach requires some kind of encryption&lt;/strong&gt;.&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font face=&quot;Tahoma&quot; size=&quot;2&quot;&gt;So in the Page_Load for your login.aspx page, write the following code -&lt;/font&gt;&lt;/p&gt;&lt;div&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;protected&lt;/span&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt; &lt;span style=&quot;COLOR: blue&quot;&gt;void&lt;/span&gt; Page_Load(&lt;span style=&quot;COLOR: blue&quot;&gt;object&lt;/span&gt; sender, &lt;span style=&quot;COLOR: teal&quot;&gt;EventArgs&lt;/span&gt; e)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;COLOR: blue&quot;&gt;string&lt;/span&gt; unescapedtokenID = &lt;span style=&quot;COLOR: teal&quot;&gt;Uri&lt;/span&gt;.UnescapeDataString(Request.QueryString[&lt;span style=&quot;COLOR: maroon&quot;&gt;&quot;ReturnURL&quot;&lt;/span&gt;]);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;COLOR: blue&quot;&gt;string&lt;/span&gt; tokenID = ParseURL(unescapedtokenID);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;COLOR: blue&quot;&gt;if&lt;/span&gt; (IsTokenValid(tokenID))&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;    &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;COLOR: teal&quot;&gt;FormsAuthentication&lt;/span&gt;.SetAuthCookie(GetUserName(tokenID), &lt;span style=&quot;COLOR: blue&quot;&gt;false&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;        &lt;/span&gt;Response.Redirect(unescapedtokenID);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;    &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 10pt&quot;&gt;&lt;o:p&gt;&lt;font face=&quot;Calibri&quot;&gt; &lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 10pt&quot;&gt;&lt;o:p&gt;&lt;font face=&quot;Tahoma&quot; size=&quot;2&quot;&gt;Basically &quot;tokenID&quot; is the token that was passed in as QueryString (or any other means), and IsTokenValid queries the ticketing web service to check the validity of the ticket. The ParseURL method is simply some magic to seperate out querystring peices out of the URL contained in the &quot;ReturnURL&quot; query string. If you&apos;re interested, the code for that looks like as below - &lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;o:p&gt;&lt;div&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;COLOR: blue&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;COLOR: blue&quot;&gt;string&lt;/span&gt; ParseURL(&lt;span style=&quot;COLOR: blue&quot;&gt;string&lt;/span&gt; unescapedTokenID)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;    &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;COLOR: teal&quot;&gt;UriBuilder&lt;/span&gt; bldr = &lt;span style=&quot;COLOR: blue&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;COLOR: teal&quot;&gt;UriBuilder&lt;/span&gt;(&lt;span style=&quot;COLOR: maroon&quot;&gt;&quot;&lt;a href=&quot;http://dummyurl&quot;&gt;http://dummyurl&lt;/a&gt;&quot;&lt;/span&gt; + unescapedTokenID);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;COLOR: teal&quot;&gt;QueryStringParser&lt;/span&gt; coll = &lt;span style=&quot;COLOR: blue&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;COLOR: teal&quot;&gt;QueryStringParser&lt;/span&gt;(bldr.Query);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;COLOR: blue&quot;&gt;return&lt;/span&gt; coll[&lt;span style=&quot;COLOR: maroon&quot;&gt;&quot;ssoToken&quot;&lt;/span&gt;];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;    &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 10pt&quot;&gt;&lt;o:p&gt;&lt;font face=&quot;Calibri&quot;&gt;&lt;/font&gt;&lt;/o:p&gt; &lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 10pt&quot;&gt;&lt;o:p&gt;&lt;font face=&quot;Tahoma&quot; size=&quot;2&quot;&gt;The QueryStringParser class looks like this - &lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;o:p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;internal&lt;/span&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt; &lt;span style=&quot;COLOR: blue&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;COLOR: teal&quot;&gt;QueryStringParser&lt;/span&gt; : System.Collections.Specialized.&lt;span style=&quot;COLOR: teal&quot;&gt;NameValueCollection&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;    &lt;/span&gt;&lt;span style=&quot;COLOR: blue&quot;&gt;internal&lt;/span&gt; QueryStringParser(&lt;span style=&quot;COLOR: blue&quot;&gt;string&lt;/span&gt; s)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;    &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;COLOR: blue&quot;&gt;if&lt;/span&gt; (s.Length != 0) s = s.Substring(1);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;COLOR: blue&quot;&gt;int&lt;/span&gt; num1 = (s != &lt;span style=&quot;COLOR: blue&quot;&gt;null&lt;/span&gt;) ? s.Length : 0;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;COLOR: blue&quot;&gt;for&lt;/span&gt; (&lt;span style=&quot;COLOR: blue&quot;&gt;int&lt;/span&gt; num2 = 0; num2 &amp;lt; num1; num2++)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;        &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;COLOR: blue&quot;&gt;int&lt;/span&gt; num3 = num2;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;COLOR: blue&quot;&gt;int&lt;/span&gt; num4 = -1;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;COLOR: blue&quot;&gt;while&lt;/span&gt; (num2 &amp;lt; num1)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;            &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;                &lt;/span&gt;&lt;span style=&quot;COLOR: blue&quot;&gt;char&lt;/span&gt; ch1 = s[num2];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;                &lt;/span&gt;&lt;span style=&quot;COLOR: blue&quot;&gt;if&lt;/span&gt; (ch1 == &lt;span style=&quot;COLOR: maroon&quot;&gt;&apos;=&apos;&lt;/span&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;                &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;                    &lt;/span&gt;&lt;span style=&quot;COLOR: blue&quot;&gt;if&lt;/span&gt; (num4 &amp;lt; 0)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;                    &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;                        &lt;/span&gt;num4 = num2;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;                    &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;                &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;                &lt;/span&gt;&lt;span style=&quot;COLOR: blue&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;COLOR: blue&quot;&gt;if&lt;/span&gt; (ch1 == &lt;span style=&quot;COLOR: maroon&quot;&gt;&apos;&amp;amp;&apos;&lt;/span&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;                &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;                    &lt;/span&gt;&lt;span style=&quot;COLOR: blue&quot;&gt;break&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;                &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;                &lt;/span&gt;num2++;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;            &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;COLOR: blue&quot;&gt;string&lt;/span&gt; text1 = &lt;span style=&quot;COLOR: blue&quot;&gt;null&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;COLOR: blue&quot;&gt;string&lt;/span&gt; text2 = &lt;span style=&quot;COLOR: blue&quot;&gt;null&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;COLOR: blue&quot;&gt;if&lt;/span&gt; (num4 &amp;gt;= 0)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;            &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;                &lt;/span&gt;text1 = s.Substring(num3, num4 - num3);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;        &lt;/span&gt;text2 = s.Substring(num4 + 1, (num2 - num4) - 1);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;            &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;COLOR: blue&quot;&gt;else&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;            &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;                &lt;/span&gt;text2 = s.Substring(num3, num2 - num3);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;            &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;            &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;COLOR: blue&quot;&gt;base&lt;/span&gt;.Add(&lt;span style=&quot;COLOR: teal&quot;&gt;HttpUtility&lt;/span&gt;.UrlDecode(text1, &lt;span style=&quot;COLOR: teal&quot;&gt;Encoding&lt;/span&gt;.ASCII), &lt;span style=&quot;COLOR: teal&quot;&gt;HttpUtility&lt;/span&gt;.UrlDecode(text2, &lt;span style=&quot;COLOR: teal&quot;&gt;Encoding&lt;/span&gt;.ASCII));&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;            &lt;/span&gt;&lt;span style=&quot;COLOR: blue&quot;&gt;if&lt;/span&gt; ((num2 == (num1 - 1)) &amp;amp;&amp;amp; (s[num2] == &lt;span style=&quot;COLOR: maroon&quot;&gt;&apos;&amp;amp;&apos;&lt;/span&gt;))&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;            &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;                &lt;/span&gt;&lt;span style=&quot;COLOR: blue&quot;&gt;base&lt;/span&gt;.Add(&lt;span style=&quot;COLOR: blue&quot;&gt;null&lt;/span&gt;, &lt;span style=&quot;COLOR: blue&quot;&gt;string&lt;/span&gt;.Empty);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;            &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;        &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;span style=&quot;mso-spacerun: yes&quot;&gt;    &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 10pt&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;}&lt;/span&gt;&lt;/p&gt;&lt;p class=&quot;MsoNormal&quot; style=&quot;MARGIN: 0in 0in 10pt&quot;&gt;&lt;span style=&quot;FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: &amp;#39;Courier New&amp;#39;; mso-no-proof: yes&quot;&gt;&lt;font face=&quot;Tahoma&quot;&gt;Thats it !! Put all these together, and you have at your hands SSO using Membership API.&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;/o:p&gt;&lt;/div&gt;</description>
  <comments>http://techonly.livejournal.com/16329.html</comments>
  <category>sso</category>
  <category>asp.net</category>
  <lj:security>public</lj:security>
  <lj:reply-count>1</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://techonly.livejournal.com/15961.html</guid>
  <pubDate>Thu, 14 Jun 2007 06:40:49 GMT</pubDate>
  <title>Single Sign-On for everyone</title>
  <link>http://techonly.livejournal.com/15961.html</link>
  <description>From &lt;a href=&quot;http://bbs.hidotnet.com/22656/ShowPost.aspx&quot;&gt;http://bbs.hidotnet.com/22656/ShowPost.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Single Sign-On (SSO) is a hot topic these days. Most clients I worked with have more than one web application running under different versions of .NET framework in different subdomains, or even in different domains and they want to let the user login once and stay logged in when switching to a different web site. Today we will implement SSO and see if we can make it work in different scenarios. We will start with a simple case and gradually build upon it:&lt;/p&gt;&lt;ol&gt;&lt;li&gt;SSO for parent and child application in the virtual sub-directory &lt;li&gt;SSO using different authorization credentials (username mapping) &lt;li&gt;SSO for two applications in two sub-domains of the same domain &lt;li&gt;SSO when applications run under different versions of .NET &lt;li&gt;SSO for two applications in different domains. &lt;li&gt;SSO for mixed-mode authentication (Forms and Windows)&lt;/li&gt;&lt;/ol&gt;&lt;b&gt;&lt;p&gt;1. SSO for parent and child application in the virtual sub-directory&lt;br&gt;&lt;br&gt;&lt;/b&gt;Lets assume that we have two .NET applications - Foo and Bar, and Bar is running in a virtual sub-directory of Foo (&lt;a href=&quot;http://foo.com/bar&quot;&gt;http://foo.com/bar&lt;/a&gt;). Both applications implement Forms authentication. Implementation of Forms authentication requires you to override the Application_AuthenticateRequest, where you perform the authentication and upon successful authentication, call FormsAuthentication.RedirectFromLoginPage, passing in the logged-in user name (or any other piece of information that identifies the user in the system) as a parameter. In ASP.NET the logged-in user status is persisted by storing the cookie on the client computer. When you call RedirectFromLoginPage, a cookie is created which contains an encrypted FormsAuthenticationTicket with the name of the logged-in user . There is a section in web.config that defines how the cookie is created:&lt;/p&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;&lt;p&gt;&amp;lt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#800000&quot; size=&quot;2&quot;&gt;authentication&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#ff0000&quot; size=&quot;2&quot;&gt;mode&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;=&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;Forms&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;&amp;gt;&lt;br&gt;   &amp;lt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#800000&quot; size=&quot;2&quot;&gt;forms&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#ff0000&quot; size=&quot;2&quot;&gt;name&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;=&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;.FooAuth&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#ff0000&quot; size=&quot;2&quot;&gt;protection&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;=&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;All&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#ff0000&quot; size=&quot;2&quot;&gt;timeout&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;=&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;60&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#ff0000&quot; size=&quot;2&quot;&gt;loginUrl&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;=&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;login.aspx&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;/&amp;gt;&lt;br&gt;&amp;lt;/&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#800000&quot; size=&quot;2&quot;&gt;authentication&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;&amp;gt;&lt;/p&gt;&lt;p&gt; &amp;lt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#800000&quot; size=&quot;2&quot;&gt;authentication&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#ff0000&quot; size=&quot;2&quot;&gt;mode&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;=&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;Forms&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;&amp;gt;&lt;br&gt;   &amp;lt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#800000&quot; size=&quot;2&quot;&gt;forms&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#ff0000&quot; size=&quot;2&quot;&gt;name&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;=&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;.BarAuth&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#ff0000&quot; size=&quot;2&quot;&gt;protection&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;=&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;All&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#ff0000&quot; size=&quot;2&quot;&gt;timeout&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;=&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;60&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#ff0000&quot; size=&quot;2&quot;&gt;loginUrl&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;=&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;login.aspx&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt; /&amp;gt;&lt;br&gt;&amp;lt;/&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#800000&quot; size=&quot;2&quot;&gt;authentication&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;&amp;gt;&lt;/p&gt;&lt;/font&gt;&lt;p&gt;The important attributes here are &lt;b&gt;name&lt;/b&gt; and &lt;b&gt;protection. &lt;/b&gt;If you make them match for both Foo and Bar applications, they will both write and read the same cookie using the same protection level, effectively providing SSO:&lt;/p&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;&lt;p&gt;&amp;lt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#800000&quot; size=&quot;2&quot;&gt;authentication&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#ff0000&quot; size=&quot;2&quot;&gt;mode&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;=&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;Forms&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;&amp;gt;&lt;br&gt;   &amp;lt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#800000&quot; size=&quot;2&quot;&gt;forms&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#ff0000&quot; size=&quot;2&quot;&gt;name&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;=&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;.SSOAuth&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#ff0000&quot; size=&quot;2&quot;&gt;protection&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;=&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;All&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#ff0000&quot; size=&quot;2&quot;&gt;timeout&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;=&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;60&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#ff0000&quot; size=&quot;2&quot;&gt;loginUrl&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;=&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;login.aspx&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt; /&amp;gt;&lt;br&gt;&amp;lt;/&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#800000&quot; size=&quot;2&quot;&gt;authentication&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;&amp;gt;&lt;/p&gt;&lt;/font&gt;&lt;p&gt;When protection attribute is set to &quot;All&quot;, both encryption and validation (via hash) is applied to the cookie. The default validation and encryption keys are stored in the machine.config file and can be overridden in the application’s web.config file. The default value is this:&lt;/p&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;&lt;p&gt;&amp;lt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#800000&quot; size=&quot;2&quot;&gt;machineKey&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#ff0000&quot; size=&quot;2&quot;&gt;validationKey&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;=&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;AutoGenerate,IsolateApps&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#ff0000&quot; size=&quot;2&quot;&gt;decryptionKey&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;=&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt; AutoGenerate,IsolateApps&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#ff0000&quot; size=&quot;2&quot;&gt;validation&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;=&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;SHA1&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt; /&amp;gt;&lt;/p&gt;&lt;/font&gt;&lt;p&gt;IsolateApps means that a different key will be generated for every application. We can’t have that. In order for the cookie to be encrypted and decrypted with the same key in all applications either remove the IsolateApps option or better yet, add the same concrete key to the web.config of all applications using SSO:&lt;/p&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;&lt;p&gt;&amp;lt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#800000&quot; size=&quot;2&quot;&gt;machineKey&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#ff0000&quot; size=&quot;2&quot;&gt;validationKey&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;=&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;F9D1A2D3E1D3E2F7B3D9F90FF3965ABDAC304902&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#ff0000&quot; size=&quot;2&quot;&gt;decryptionKey&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;=&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;F9D1A2D3E1D3E2F7B3D9F90FF3965ABDAC304902F8D923AC&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#ff0000&quot; size=&quot;2&quot;&gt;validation&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;=&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;SHA1&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt; /&amp;gt;&lt;/p&gt;&lt;/font&gt;&lt;p&gt;If you are authenticating against the same users store, this is all it takes – a few changes to the web.config files. &lt;/p&gt;&lt;b&gt;&lt;p&gt;2. SSO using different authorization credentials (username mapping)&lt;/p&gt;&lt;/b&gt;&lt;p&gt;But what if the Foo application authenticates against its own database and the Bar application uses Membership API or some other form of authentication? In this case the automatic cookie that is created on the Foo is not going to be any good for the Bar, since it will contain the user name that makes no sense to the Bar. &lt;/p&gt;&lt;p&gt;To make it work, you will need to create the second authentication cookie especially for the Bar application. You will also need a way to map the Foo user to the Bar user. Lets assume that you have a user &quot;John Doe&quot; logging in to the Foo application and you determined that this user is identified as &quot;johnd&quot; in the Bar application. In the Foo authentication method you will add the following code:&lt;/p&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008080&quot; size=&quot;2&quot;&gt;&lt;p&gt;FormsAuthenticationTicket&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt; fat = &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;new&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008080&quot; size=&quot;2&quot;&gt;FormsAuthenticationTicket&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;(1, &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#ffa500&quot; size=&quot;2&quot;&gt;&quot;johnd&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;, &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008080&quot; size=&quot;2&quot;&gt;DateTime&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;.Now, &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008080&quot; size=&quot;2&quot;&gt;DateTime&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;.Now.AddYears(1), true, &quot;&quot;);&lt;br&gt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008080&quot; size=&quot;2&quot;&gt;HttpCookie&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt; cookie = &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;new&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008080&quot; size=&quot;2&quot;&gt;HttpCookie&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;(&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#800000&quot; size=&quot;2&quot;&gt;&quot;.BarAuth&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;);&lt;br&gt;cookie.Value = &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008080&quot; size=&quot;2&quot;&gt;FormsAuthentication&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;.Encrypt(fat);&lt;br&gt;cookie.Expires = fat.Expiration;&lt;br&gt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008080&quot; size=&quot;2&quot;&gt;HttpContext&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;.Current.Response.Cookies.Add(cookie);&lt;/p&gt;&lt;p&gt;FormsAuthentication.RedirectFromLoginPage(&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#ff9900&quot; size=&quot;2&quot;&gt;John Doe&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;);&lt;/p&gt;&lt;/font&gt;&lt;p&gt;User names are hard-coded for demonstration purposes only. This code snippet creates the FormsAuthenticationTicket for the Bar application and stuffs it with the user name that makes sense in the context of the Bar application. And then it calls RedirectFromLoginPage to create the correct authentication cookie for the Foo application. If you changed the name of forms authentication cookie to be the same for both applications (see our previous example), make sure that they are different now, since we are not using the same cookie for both sites anymore:&lt;/p&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;&lt;p&gt;&amp;lt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#800000&quot; size=&quot;2&quot;&gt;authentication&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#ff0000&quot; size=&quot;2&quot;&gt;mode&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;=&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;Forms&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;&amp;gt;&lt;br&gt;   &amp;lt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#800000&quot; size=&quot;2&quot;&gt;forms&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#ff0000&quot; size=&quot;2&quot;&gt;name&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;=&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;.FooAuth&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#ff0000&quot; size=&quot;2&quot;&gt;protection&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;=&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;All&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#ff0000&quot; size=&quot;2&quot;&gt;timeout&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;=&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;60&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#ff0000&quot; size=&quot;2&quot;&gt;loginUrl&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;=&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;login.aspx&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#ff0000&quot; size=&quot;2&quot;&gt;slidingExpiration&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;=&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;true&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;/&amp;gt;&lt;br&gt;&amp;lt;/&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#800000&quot; size=&quot;2&quot;&gt;authentication&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;&amp;gt;&lt;/p&gt;&lt;p&gt; &amp;lt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#800000&quot; size=&quot;2&quot;&gt;authentication&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#ff0000&quot; size=&quot;2&quot;&gt;mode&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;=&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;Forms&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;&amp;gt;&lt;br&gt;   &amp;lt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#800000&quot; size=&quot;2&quot;&gt;forms&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#ff0000&quot; size=&quot;2&quot;&gt;name&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;=&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;.BarAuth&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#ff0000&quot; size=&quot;2&quot;&gt;protection&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;=&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;All&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#ff0000&quot; size=&quot;2&quot;&gt;timeout&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;=&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;60&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#ff0000&quot; size=&quot;2&quot;&gt;loginUrl&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;=&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;login.aspx&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#ff0000&quot; size=&quot;2&quot;&gt;slidingExpiration&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;=&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;true&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;/&amp;gt;&lt;br&gt;&amp;lt;/&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#800000&quot; size=&quot;2&quot;&gt;authentication&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;&amp;gt;&lt;/p&gt;&lt;/font&gt;&lt;p&gt;Now when the user is logged in to Foo, he is mapped to the Bar user and the Bar authentication ticket is created along with the Foo authentication ticket. If you want it to work in the reverse direction, add similar code to the Bar application:&lt;/p&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008080&quot; size=&quot;2&quot;&gt;&lt;p&gt;FormsAuthenticationTicket&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt; fat = &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;new&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008080&quot; size=&quot;2&quot;&gt;FormsAuthenticationTicket&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;(1, &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#ffa500&quot; size=&quot;2&quot;&gt;&quot;John Doe&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;, &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008080&quot; size=&quot;2&quot;&gt;DateTime&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;.Now, &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008080&quot; size=&quot;2&quot;&gt;DateTime&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;.Now.AddYears(1), true, &quot;&quot;);&lt;br&gt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008080&quot; size=&quot;2&quot;&gt;HttpCookie&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt; cookie = &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;new&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008080&quot; size=&quot;2&quot;&gt;HttpCookie&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;(&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#800000&quot; size=&quot;2&quot;&gt;&quot;.FooAuth&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;);&lt;br&gt;cookie.Value = &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008080&quot; size=&quot;2&quot;&gt;FormsAuthentication&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;.Encrypt(fat);&lt;br&gt;cookie.Expires = fat.Expiration;&lt;br&gt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008080&quot; size=&quot;2&quot;&gt;HttpContext&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;.Current.Response.Cookies.Add(cookie);&lt;/p&gt;&lt;p&gt;FormsAuthentication.RedirectFromLoginPage(&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#ff9900&quot; size=&quot;2&quot;&gt;johnd&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;);&lt;/p&gt;&lt;/font&gt;&lt;p&gt;Also make sure that you have the &amp;lt;machineKey&amp;gt; element in web.config of both applications with matching validation and encryption keys.&lt;/p&gt;&lt;b&gt;&lt;p&gt;3. SSO for two applications in two sub-domains of the same domain&lt;/p&gt;&lt;/b&gt;&lt;p&gt;Now what if Foo and Bar are configured to run under different domains &lt;a href=&quot;http://foo.com&quot;&gt;http://foo.com&lt;/a&gt; and &lt;a href=&quot;http://bar.foo.com&quot;&gt;http://bar.foo.com&lt;/a&gt;. The code above will not work because the cookies will be stored in different files and will not be visible to both applications. In order to make it work, we will need to create domain-level cookies that are visible to all sub-domains. We can’t use RedirectFromLoginPage method anymore, since it doesn’t have the flexibility to create a domain-level cookie. So we do it manually:&lt;/p&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008080&quot; size=&quot;2&quot;&gt;&lt;p&gt;FormsAuthenticationTicket&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt; fat = &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;new&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008080&quot; size=&quot;2&quot;&gt;FormsAuthenticationTicket&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;(1, &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#ffa500&quot; size=&quot;2&quot;&gt;&quot;johnd&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;, &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008080&quot; size=&quot;2&quot;&gt;DateTime&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;.Now, &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008080&quot; size=&quot;2&quot;&gt;DateTime&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;.Now.AddYears(1), true, &quot;&quot;);&lt;br&gt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008080&quot; size=&quot;2&quot;&gt;HttpCookie&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt; cookie = &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;new&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008080&quot; size=&quot;2&quot;&gt;HttpCookie&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;(&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#800000&quot; size=&quot;2&quot;&gt;&quot;.BarAuth&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;);&lt;br&gt;cookie.Value = &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008080&quot; size=&quot;2&quot;&gt;FormsAuthentication&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;.Encrypt(fat);&lt;br&gt;cookie.Expires = fat.Expiration;&lt;br&gt;&lt;font size=&quot;3&quot;&gt;cookie.Domain = &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#800000&quot; size=&quot;2&quot;&gt;&quot;.foo.com&quot;;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&lt;br&gt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008080&quot; size=&quot;2&quot;&gt;HttpContext&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;.Current.Response.Cookies.Add(cookie);&lt;/p&gt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008080&quot; size=&quot;2&quot;&gt;&lt;p&gt;FormsAuthenticationTicket&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt; fat = &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;new&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008080&quot; size=&quot;2&quot;&gt;FormsAuthenticationTicket&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;(1, &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#ffa500&quot; size=&quot;2&quot;&gt;&quot;John Doe&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;, &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008080&quot; size=&quot;2&quot;&gt;DateTime&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;.Now, &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008080&quot; size=&quot;2&quot;&gt;DateTime&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;.Now.AddYears(1), true, &quot;&quot;);&lt;br&gt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008080&quot; size=&quot;2&quot;&gt;HttpCookie&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt; cookie = &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;new&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008080&quot; size=&quot;2&quot;&gt;HttpCookie&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;(&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#800000&quot; size=&quot;2&quot;&gt;&quot;.FooAuth&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;);&lt;br&gt;cookie.Value = &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008080&quot; size=&quot;2&quot;&gt;FormsAuthentication&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;.Encrypt(fat);&lt;br&gt;cookie.Expires = fat.Expiration;&lt;br&gt;&lt;font size=&quot;3&quot;&gt;cookie.Domain = &lt;/font&gt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#800000&quot; size=&quot;2&quot;&gt;&quot;.foo.com&quot;;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&lt;br&gt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008080&quot; size=&quot;2&quot;&gt;HttpContext&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;.Current.Response.Cookies.Add(cookie);&lt;/p&gt;&lt;/font&gt;&lt;p&gt;Note the highlighted lines. By explicitly setting the cookie domain to &quot;.foo.com&quot; we ensure that this cookie will be visible in both &lt;a href=&quot;http://foo.com&quot;&gt;http://foo.com&lt;/a&gt; and &lt;a href=&quot;http://bar.foo.com&quot;&gt;http://bar.foo.com&lt;/a&gt; or any other sub-domain. You can also specifically set the Bar authentication cookie domain to &quot;bar.foo.com&quot;. It is more secure, since other sub-domains can’t see it now. Also notice that RFC 2109 requires two periods in the cookie domain value, therefore we add a period in the front – &quot;.foo.com&quot;&lt;/p&gt;&lt;p&gt;Again, make sure that you have the same &amp;lt;machineKey&amp;gt; element in web.config of both applications. There is only one exception to this rule and it is explained in the next secion.&lt;/p&gt;&lt;b&gt;&lt;p&gt;4. SSO when applications run under different versions of .NET&lt;/p&gt;&lt;/b&gt;&lt;p&gt;It is possible that Foo and Bar applications run under different version of .NET. In this case the above examples will not work. It turns out that ASP.NET 2.0 is using a different encryption method for authorization tickets. In ASP.NET 1.1 it was 3DES, in ASP.NET 2.0 it is AES. Fortunately, a new attribute was introduced in ASP.NET 2.0 for backwards compatibility&lt;/p&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;&lt;p&gt;&amp;lt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#800000&quot; size=&quot;2&quot;&gt;machineKey&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#ff0000&quot; size=&quot;2&quot;&gt;validationKey&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;=&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;F9D1A2D3E1D3E2F7B3D9F90FF3965ABDAC304902&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#ff0000&quot; size=&quot;2&quot;&gt;decryptionKey&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;=&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;F9D1A2D3E1D3E2F7B3D9F90FF3965ABDAC304902F8D923AC&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#ff0000&quot; size=&quot;2&quot;&gt;validation&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;=&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;SHA1&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#ff0000&quot; size=&quot;2&quot;&gt;decryption&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;=&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;3DES&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt; /&amp;gt;&lt;/p&gt;&lt;/font&gt;&lt;p&gt;Setting &lt;font face=&quot;Courier New&quot; color=&quot;#ff0000&quot;&gt;decryption&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot;&gt;=&lt;/font&gt;&lt;font face=&quot;Courier New&quot;&gt;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot;&gt;3DES&lt;/font&gt;&lt;font face=&quot;Courier New&quot;&gt;&quot; &lt;/font&gt;will make ASP.NET 2.0 use the old encryption method, making the cookies compatible again. Don’t try to add this attribute to the web.config of the ASP.NET 1.1 application. It will cause an error.&lt;/p&gt;&lt;b&gt;&lt;p&gt;5. SSO for two applications in different domains.&lt;/p&gt;&lt;/b&gt;&lt;p&gt;We’ve been quite successful creating shared authentication cookies so far, but what if Foo and Bar are in different domains – &lt;a href=&quot;http://foo.com&quot;&gt;http://foo.com&lt;/a&gt; and &lt;a href=&quot;http://bar.com&quot;&gt;http://bar.com&lt;/a&gt;? They cannot possibly share a cookie or create a second cookie for each other. In this case each site will need to create its own cookies, and call the other site to verify if the user is logged in elsewhere. One way to do it is via a series of redirects.&lt;/p&gt;&lt;p&gt;In order to achieve that, we will create a special page (we’ll call it sso.aspx) on both web sites. The purpose of this page is to check if the cookie exists in its domain and return the logged in user name, so that the other application can create a similar cookie in its own domain. This is the sso.aspx from Bar.com:&lt;/p&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&lt;p&gt;&amp;lt;%&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;@&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#800000&quot; size=&quot;2&quot;&gt;Page&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#ff0000&quot; size=&quot;2&quot;&gt;Language&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;=&quot;C#&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt; %&amp;gt;&lt;/p&gt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;&lt;p&gt;&amp;lt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#800000&quot; size=&quot;2&quot;&gt;script&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#ff0000&quot; size=&quot;2&quot;&gt;language&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;=&quot;C#&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#ff0000&quot; size=&quot;2&quot;&gt;runat&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;=&quot;server&quot;&amp;gt;&lt;/p&gt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;void&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt; Page_Load()&lt;br&gt;{&lt;br&gt;   &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008000&quot; size=&quot;2&quot;&gt;// this is our caller, we will need to redirect back to it eventually&lt;br&gt;   &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008080&quot; size=&quot;2&quot;&gt;UriBuilder&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt; uri = &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;new&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008080&quot; size=&quot;2&quot;&gt;UriBuilder&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;(Request.UrlReferrer); &lt;/p&gt;&lt;p&gt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008080&quot; size=&quot;2&quot;&gt;   HttpCookie&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt; c = &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008080&quot; size=&quot;2&quot;&gt;HttpContext&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;.Current.Request.Cookies[&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#800000&quot; size=&quot;2&quot;&gt;&quot;.BarAuth&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;];&lt;/p&gt;&lt;p&gt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;   if&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt; (c != &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;null&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt; &amp;amp;&amp;amp; c.HasKeys) &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008000&quot; size=&quot;2&quot;&gt;// the cookie exists!&lt;br&gt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;   {&lt;br&gt;      &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;try&lt;br&gt;      &lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;{&lt;br&gt;         &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;string&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt; cookie = &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008080&quot; size=&quot;2&quot;&gt;HttpContext&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;.Current.Server.UrlDecode(c.Value);&lt;br&gt;         &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008080&quot; size=&quot;2&quot;&gt;FormsAuthenticationTicket&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt; fat = &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008080&quot; size=&quot;2&quot;&gt;FormsAuthentication&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;.Decrypt(cookie);         &lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;         uri.Query = uri.Query + &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#800000&quot; size=&quot;2&quot;&gt;&quot;&amp;amp;ssoauth=&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt; + fat.Name; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008000&quot; size=&quot;2&quot;&gt;// add logged-in user name to the query&lt;br&gt;      &lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;}&lt;br&gt;      &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;catch&lt;br&gt;      &lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;{&lt;br&gt;      }&lt;br&gt;   }&lt;br&gt;   Response.Redirect(uri.ToString()); &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008000&quot; size=&quot;2&quot;&gt;// redirect back to the caller&lt;br&gt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;} &lt;/p&gt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;&lt;p&gt;&amp;lt;/&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#800000&quot; size=&quot;2&quot;&gt;script&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;&amp;gt;&lt;/p&gt;&lt;/font&gt;&lt;p&gt;This page always redirects back to the caller. If the authentication cookie exists on Bar.com, it is decrypted and the user name is passed back in the query string parameter &lt;i&gt;ssoauth&lt;/i&gt;.&lt;/p&gt;&lt;p&gt;On the other end (Foo.com), we need to insert some code into the http request processing pipeline. It can be in Application_BeginRequest event or in a custom HttpHandler or HttpModule. The idea is to intercept all page requests to Foo.com as early as possible to verify if authentication cookie exists:&lt;/p&gt;&lt;p&gt;1. If authentication cookie exists on Foo.com, continue processing the request. User is logged in on Foo.com&lt;br&gt;2. If authentication cookie doesn’t exist, redirect to Bar.com/sso.aspx.&lt;br&gt;3. If the current request is the redirect back from Bar.com/sso.aspx, analyse the ssoauth parameter and create an authentication cookie if necessary.&lt;/p&gt;&lt;p&gt;It looks pretty simple, but we have to watch out for infinite loops:&lt;/p&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008000&quot; size=&quot;2&quot;&gt;&lt;p&gt;// see if the user is logged in&lt;br&gt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008080&quot; size=&quot;2&quot;&gt;HttpCookie&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt; c = &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008080&quot; size=&quot;2&quot;&gt;HttpContext&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;.Current.Request.Cookies[&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#800000&quot; size=&quot;2&quot;&gt;&quot;.FooAuth&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;];&lt;/p&gt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;&lt;p&gt;if&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt; (c != &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;null&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt; &amp;amp;&amp;amp; c.HasKeys) &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008000&quot; size=&quot;2&quot;&gt;// the cookie exists!&lt;br&gt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;{&lt;br&gt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;   try&lt;br&gt;   &lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;{&lt;br&gt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;      string&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt; cookie = &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008080&quot; size=&quot;2&quot;&gt;HttpContext&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;.Current.Server.UrlDecode(c.Value);&lt;br&gt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008080&quot; size=&quot;2&quot;&gt;      FormsAuthenticationTicket&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt; fat = &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008080&quot; size=&quot;2&quot;&gt;FormsAuthentication&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;.Decrypt(cookie);&lt;br&gt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;      return&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008000&quot; size=&quot;2&quot;&gt;// cookie decrypts successfully, continue processing the page&lt;br&gt;   &lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;}&lt;br&gt;   &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;catch&lt;br&gt;   &lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;{&lt;br&gt;   &lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;}&lt;br&gt;}&lt;/p&gt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008000&quot; size=&quot;2&quot;&gt;&lt;p&gt;// the authentication cookie doesn&apos;t exist - ask Bar.com if the user is logged in there&lt;br&gt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008080&quot; size=&quot;2&quot;&gt;UriBuilder&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt; uri = &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;new&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008080&quot; size=&quot;2&quot;&gt;UriBuilder&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;(Request.UrlReferrer);&lt;/p&gt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;&lt;p&gt;if&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt; (uri.Host != &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#800000&quot; size=&quot;2&quot;&gt;&quot;bar.com&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt; || uri.Path != &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#800000&quot; size=&quot;2&quot;&gt;&quot;/sso.aspx&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;) &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008000&quot; size=&quot;2&quot;&gt;// prevent infinite loop&lt;br&gt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;{&lt;br&gt;   Response.Redirect(&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;&lt;a href=&quot;http://bar.com/sso.aspx&quot;&gt;&lt;u&gt;http://bar.com/sso.aspx&lt;/u&gt;&lt;/a&gt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;);&lt;br&gt;}&lt;br&gt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;else&lt;br&gt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;{&lt;br&gt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008000&quot; size=&quot;2&quot;&gt;   // we are here because the request we are processing is actually a response from bar.com&lt;/p&gt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&lt;p&gt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;   if&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt; (Request.QueryString[&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#800000&quot; size=&quot;2&quot;&gt;&quot;ssoauth&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;] == &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;null&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;)&lt;br&gt;   {&lt;br&gt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008000&quot; size=&quot;2&quot;&gt;      // Bar.com also didn&apos;t have the authentication cookie&lt;br&gt;      &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;return&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008000&quot; size=&quot;2&quot;&gt;// continue normally, this user is not logged-in &lt;br&gt;   &lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;} &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;else&lt;br&gt;   &lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;{&lt;/p&gt;&lt;p&gt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008000&quot; size=&quot;2&quot;&gt;      // user is logged in to Bar.com and we got his name!&lt;br&gt;      &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;string&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt; userName = (&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;string&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;)Request.QueryString[&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#800000&quot; size=&quot;2&quot;&gt;&quot;ssoauth&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;];&lt;br&gt;   &lt;br&gt;      &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008000&quot; size=&quot;2&quot;&gt;// let&apos;s create a cookie with the same name&lt;br&gt;      &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008080&quot; size=&quot;2&quot;&gt;FormsAuthenticationTicket&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt; fat = &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;new&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008080&quot; size=&quot;2&quot;&gt;FormsAuthenticationTicket&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;(1, userName, &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008080&quot; size=&quot;2&quot;&gt;DateTime&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;.Now, &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008080&quot; size=&quot;2&quot;&gt;DateTime&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;.Now.AddYears(1), &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;true&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;, &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#800000&quot; size=&quot;2&quot;&gt;&quot;&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;);&lt;br&gt;      &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008080&quot; size=&quot;2&quot;&gt;HttpCookie&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt; cookie = &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;new&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt; &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008080&quot; size=&quot;2&quot;&gt;HttpCookie&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;(&lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#800000&quot; size=&quot;2&quot;&gt;&quot;.FooAuth&quot;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;);&lt;br&gt;      cookie.Value = &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008080&quot; size=&quot;2&quot;&gt;FormsAuthentication&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;.Encrypt(fat);&lt;br&gt;      cookie.Expires = fat.Expiration;&lt;br&gt;      &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#008080&quot; size=&quot;2&quot;&gt;HttpContext&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;.Current.Response.Cookies.Add(cookie);&lt;br&gt;   &lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;}&lt;br&gt;}&lt;/p&gt;&lt;/font&gt;&lt;p&gt;The same code should be placed on both sites, just make sure you are using correct cookie names (.FooAuth vs. .BarAuth) on each site. Since the cookie is not actually shared, the applications can have different &amp;lt;machineKey&amp;gt; elements. It is not necessary to synchronize the encryption and validation keys. &lt;/p&gt;&lt;p&gt;Some of us may cringe at the security implications of passing the user name in the query string. A couple of things can be done to protect it. First of all we are checking the referrer and we will not accept the ssoauth parameter from any source other then bar.com/sso.aspx (or foo.com/ssp.aspx). Secondly, the name can easily be encrypted with a shared key. If Foo and Bar are using different authentication mechanisms, additional user information (e.g. e-mail address) can be passed along similarly.&lt;/p&gt;&lt;b&gt;&lt;p&gt;6. SSO for mixed-mode authentication (Forms and Windows)&lt;/p&gt;&lt;/b&gt;&lt;p&gt;So far we have dealt with Forms authentication only. But what if we want to authenticate Internet users via Forms authentication first and if it fails, check if the Intranet user is authenticated on the NT domain? In theory we can check the following parameter to see if there is a Windows logon associated with the request: &lt;/p&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&lt;p&gt;Request.ServerVariables[&quot;LOGON_USER&quot;]&lt;/p&gt;&lt;/font&gt;&lt;p&gt;However, unless our site has Anonymous Access disabled, this value is always empty. We can disable Anonymous Access and enable Integrate Windows Authentication for our site in the IIS control panel. Now the LOGON_USER value contains the NT domain name of the logged in Intranet user. But all Internet users get challenged for the Windows login name and password. Not cool. We need to be able to let the Internet users login via Forms authentication and if it fails, check their Windows domain credentials.&lt;/p&gt;&lt;p&gt;One way to solve this problem is to have a special entry page for Intranet users that has Integrate Windows Authentication enabled, validates the domain user, creates a Forms cookie and redirects to the main web site. We can even conceal the fact that Intranet users are hitting a different page by making a Server.Transfer. &lt;/p&gt;&lt;p&gt;There is also an easier solution. It works because of the way IIS handles the authentication process. If anonymous access is enabled for a web site, IIS is passing requests right through to the ASP.NET runtime. It doesn’t attempt to perform any kind of authentication. However, if the request results in an authentication error (401), IIS will attempt an alternative authentication method specified for this site. You need to enable both Anonymous Access and Integrated Windows Authentication and execute the following code if Forms authentication fails:&lt;/p&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#0000ff&quot; size=&quot;2&quot;&gt;&lt;p&gt;if&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt; (System.Web.HttpContext.Current.Request.ServerVariables[&quot;LOGON_USER&quot;] == &quot;&quot;) { &lt;br&gt;   System.Web.HttpContext.Current.Response.StatusCode = 401; &lt;br&gt;   System.Web.HttpContext.Current.Response.End(); &lt;br&gt;} &lt;br&gt;&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;else &lt;br&gt;{&lt;br&gt;   &lt;/font&gt;&lt;font face=&quot;Courier New&quot; color=&quot;#339966&quot; size=&quot;2&quot;&gt;// Request.ServerVariables[&quot;LOGON_USER&quot;] has a valid domain user now!&lt;/font&gt;&lt;font face=&quot;Courier New&quot; size=&quot;2&quot;&gt;&lt;br&gt;}&lt;/p&gt;&lt;/font&gt;&lt;p&gt;When this code executes, it will check the domain user and will get an empty string initially. It will then terminate the current request and return the authentication error (401) to IIS. This will make the IIS use the alternative authentication mechanism, which in our case is Integrated Windows Authentication. If the user is already logged in to the domain, the request will be repeated, now with the NT domain user information filled-in. If the user is not logged in to the domain, he will be challenged for the Windows name/password up to 3 times. If the user cannot login after the third attempt, he will get the 403 error (access denied).&lt;/p&gt;&lt;b&gt;&lt;p&gt;Conclusion&lt;/p&gt;&lt;/b&gt;&lt;p&gt;We have examined various scenarios of Single Sign-On for two ASP.NET applications. It is also quite possible to implement SSO for heterogeneous systems spawning across different platforms. Ideas remain the same, but the implementation may require some creative thinking.&lt;/p&gt;</description>
  <comments>http://techonly.livejournal.com/15961.html</comments>
  <category>sso</category>
  <category>asp.net</category>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://techonly.livejournal.com/15651.html</guid>
  <pubDate>Thu, 14 Jun 2007 06:31:43 GMT</pubDate>
  <title>Windows Mobile开发环境搭建指南</title>
  <link>http://techonly.livejournal.com/15651.html</link>
  <description>From &lt;a href=&quot;http://blog.joycode.com/musicland/articles/38275.aspx&quot;&gt;http://blog.joycode.com/musicland/articles/38275.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;postText&quot;&gt;&lt;h2 style=&quot;MARGIN: 13pt 0cm&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 黑体; mso-ascii-font-family: Verdana&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;3&quot;&gt;内容简介&lt;/font&gt;&lt;/span&gt;&lt;/h2&gt;&lt;p class=&quot;MsoBodyTextFirstIndent&quot; style=&quot;MARGIN: 0cm 0cm 6pt&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;本文描述了如何搭建典型的&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Windows Mobile&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;开发环境。介绍了相应的&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;IDE&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;、&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;SDK&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;及辅助开发工具的安装及常用配置，并对&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Windows Mobile&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;下一代开发环境的发展前景做出展望。本文适合初次接触&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Windows Mobile&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;开发的开发人员。&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;h2 style=&quot;MARGIN: 13pt 0cm&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;Windows Mobile&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 黑体; mso-ascii-font-family: Verdana&quot;&gt;开发简介&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/h2&gt;&lt;p class=&quot;MsoBodyTextFirstIndent&quot; style=&quot;MARGIN: 0cm 0cm 6pt&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;Windows Mobile&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;是微软公司操作系统产品线上重要的一环。与&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Windows 9x/NT/XP/2003&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;相比，&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Windows Mobile&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;作为完整产品线出现在公众面前的时间非常短，但它的发展却异常迅速，而在这一发展过程中，开发人员提供了绝对关键的推动力。现在，越来越多的开发人员（特别是&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;.NET&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;开发人员）希望能尽快进入&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Windows Mobile&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;的开发领域，而他们所面临的首要问题，除了熟悉&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Windows Mobile&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;平台特性之外，便是如何搭建适合的开发环境。因此，本文就将从如何搭建一个&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Windows Mobile&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;开发环境入手，对&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Windows Mobile&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;平台的开发特性进行概要描述，以期帮助开发人员迅速进入&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Windows Mobile&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;开发领域。&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;p class=&quot;MsoBodyTextFirstIndent&quot; style=&quot;MARGIN: 0cm 0cm 6pt&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;在展开本文的内容之前需要说明的一点是，&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Windows Mobile&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;平台开发主要包含以下两方面内容：&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;p class=&quot;MsoBodyTextFirstIndent&quot; style=&quot;MARGIN: 0cm 0cm 6pt 42pt; TEXT-INDENT: -21pt; mso-list: l2 level1 lfo1; tab-stops: list 42.0pt; mso-char-indent-count: 0&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;FONT-FAMILY: Wingdings; mso-bidi-font-family: Wingdings; mso-fareast-font-family: Wingdings&quot;&gt;&lt;span style=&quot;mso-list: Ignore&quot;&gt;l&lt;span style=&quot;FONT: 7pt &amp;#39;Times New Roman&amp;#39;&quot;&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;平台级开发&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;p class=&quot;MsoBodyTextFirstIndent&quot; style=&quot;MARGIN: 0cm 0cm 6pt 42pt; TEXT-INDENT: -21pt; mso-list: l2 level1 lfo1; tab-stops: list 42.0pt; mso-char-indent-count: 0&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;FONT-FAMILY: Wingdings; mso-bidi-font-family: Wingdings; mso-fareast-font-family: Wingdings&quot;&gt;&lt;span style=&quot;mso-list: Ignore&quot;&gt;l&lt;span style=&quot;FONT: 7pt &amp;#39;Times New Roman&amp;#39;&quot;&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;应用级开发&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;p class=&quot;MsoBodyTextFirstIndent&quot; style=&quot;MARGIN: 0cm 0cm 6pt&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;因为&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Windows Mobile&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;平台构建于微软的&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Windows CE&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;系列操作系统之上（当前正式商用版本为&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Windows CE .NET 4.21&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;），而&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Windows CE&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;操作系统具有非常良好的模块化特性，因此开发人员，特别是手机设备厂商，可以通过微软提供的&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Platform Builder&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;及&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;eMbedded Visual C++&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;（以下简称为&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;eVC&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;）非常方便地定制自己所需的操作系统。这对应的是上面所说的平台级开发。&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;p class=&quot;MsoBodyTextFirstIndent&quot; style=&quot;MARGIN: 0cm 0cm 6pt&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;然而，绝大多数的开发人员并不需要去构建一个全新的、个性化的系统，他们只需要关心如何构建能够运行在&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Windows Mobile&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;设备上的应用程序。为此，微软按主要智能设备自身硬件设备特性的不同以及用户体验的差异，定制出了&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Windows CE .NET 4.x&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;系列操作系统的两个主要分支，分别安装在不同的&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Windows Mobile&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;硬件设备中，从而也就构成了我们通常所说的&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Pocket PC&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;和&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Smartphone&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;。以下内容中的&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Windows Mobile&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;开发，除特指之外，均表示&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Pocket PC/Smartphone&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;开发。&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;p class=&quot;MsoBodyTextFirstIndent&quot; style=&quot;MARGIN: 0cm 0cm 6pt&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;本文中提供的大量开发工具，除单独标出的以外，均可在&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;&lt;a href=&quot;http://msdn.microsoft.com/mobility/downloads/default.aspx&quot;&gt;http://msdn.microsoft.com/mobility/downloads/default.aspx&lt;/a&gt;&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;下载。&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;h2 style=&quot;MARGIN: 13pt 0cm&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 黑体; mso-ascii-font-family: Verdana&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;3&quot;&gt;迅速搭建开发环境&lt;/font&gt;&lt;/span&gt;&lt;/h2&gt;&lt;p class=&quot;MsoBodyTextFirstIndent&quot; style=&quot;MARGIN: 0cm 0cm 6pt&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;为了进行&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Windows Mobile&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;开发，我们需要搭建相应的开发环境。所幸的是，这一环境搭建起来非常简单。&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;h3 style=&quot;MARGIN: 13pt 0cm&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 黑体; mso-ascii-font-family: Verdana&quot;&gt;安装&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Visual Studio .NET 2003&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/h3&gt;&lt;p class=&quot;MsoBodyTextFirstIndent&quot; style=&quot;MARGIN: 0cm 0cm 6pt&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;为了降低&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Windows Mobile&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;的开发难度，提高开发人员的开发效率，微软把&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;.NET Framework&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;移植到了&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Windows Mobile&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;设备上，针对&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Windows Mobile&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;设备及&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Windows CE .NET&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;操作系统设计了&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;.NET Compact Framework&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;（以下简称&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;.NET CF&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;）。而&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Visual Studio .NET 2003&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;正是开发&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;.NET CF&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;应用程序的最佳&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;IDE&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;。在&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Visual Studio .NET 2003&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;的安装中默认集成了&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;.NET CF 1.0&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;，同时提供了&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Pocket PC 2002&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;的开发模板，可以直接用来开发&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Pocket PC 2002&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;应用程序。&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;p class=&quot;MsoBodyTextFirstIndent&quot; style=&quot;MARGIN: 0cm 0cm 6pt&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;您也可以选择&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Visual Studio 2005&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;作为开发工具，目前最高版本为&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Beta 1 Refresh&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;。在&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Visual Studio 2005&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;中，默认提供了&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Pocket PC/Smartphone 2003 SE&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;（第二版）的开发模板，同时将&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Pocket PC 2003 SE&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;开发使用&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;.NET CF&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;版本升级到&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;2.0 (beta)&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;。&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;h3 style=&quot;MARGIN: 13pt 0cm&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 黑体; mso-ascii-font-family: Verdana&quot;&gt;安装&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;eVC (&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 黑体; mso-ascii-font-family: Verdana&quot;&gt;可选&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;)&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/h3&gt;&lt;p class=&quot;MsoBodyTextFirstIndent&quot; style=&quot;MARGIN: 0cm 0cm 6pt&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;以上环境已经完全可以基于&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;.NET CF&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;开发&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Windows Mobile&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;应用程序。但如果您想使用&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;C/C++&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;语言来进行&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;native&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;开发，或者想在&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Windows Mobile&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;设备上开发&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;COM&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;组件及应用，那么可以选择&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;eVC&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;作为开发工具。目前&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;eVC&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;的最高版本为&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;4.0 + SP4&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;，请确保安装了最新的补丁包。&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;p class=&quot;MsoBodyTextFirstIndent&quot; style=&quot;MARGIN: 0cm 0cm 6pt&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;也许您会问：既然已经有了&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Visual Studio .NET&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;环境，为什么还要使用&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;eVC&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;作为开发工具呢？这主要是因为，当前的&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;.NET CF&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;功能相对而言还很不完整，有很多&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Windows CE .NET&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;操作系统的核心功能没有被封装入&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;.NET CF&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;，如：加密&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;解密、网络底层通讯、&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;COM&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;互操作、&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;RAPI&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;等等。为了完成上述操作，我们或者使用平台调用&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;(P/Invoke)&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;以托管方式开发，或者使用&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;eVC&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;直接针对系统底层进行&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;native&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;开发。对于&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;COM&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;互操作，目前&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;.NET CF&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;还不提供&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;COM&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;互操作&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;(Interop)&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;机制，只能使用&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;eVC&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;进行&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;C/C++ COM&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;开发。好消息是，在&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;.NET CF 2.0&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;中将提供功能强大的&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;COM&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;互操作特性支持，同时也将在&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Visual C++ 2005&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;环境中同时提供&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;managed&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;及&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;native&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;开发功能，这样所有的开发工作将完全整合在&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Visual Studio 2005&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;同一环境中。&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;h3 style=&quot;MARGIN: 13pt 0cm&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 黑体; mso-ascii-font-family: Verdana&quot;&gt;安装&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Pocket PC/Smartphone 2003 SDK&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/h3&gt;&lt;p class=&quot;MsoBodyTextFirstIndent&quot; style=&quot;MARGIN: 0cm 0cm 6pt&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;为了开发&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Pocket PC 2003&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;或&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Smartphone 2003&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;应用程序，您还需要安装&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Pocket PC 2003 SDK&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;或&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Smartphone 2003 SDK&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;。值得注意的是，这两款&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;SDK&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;中所包含的模拟器均为英语环境，如果您想使用简体中文环境的模拟器，请去微软网站上单独下载。&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;p class=&quot;MsoBodyTextFirstIndent&quot; style=&quot;MARGIN: 0cm 0cm 6pt&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;如果您使用&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Visual Studio 2005&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;开发&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Windows Mobile&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;应用程序，则不需要单独安装相应的&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;SDK&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;，因为&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;SDK&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;已经被默认集成至了&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Visual Studio 2005&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;环境中。&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;h3 style=&quot;MARGIN: 13pt 0cm&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;SQL Server CE (&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 黑体; mso-ascii-font-family: Verdana&quot;&gt;可选&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;)&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/h3&gt;&lt;p class=&quot;MsoBodyTextFirstIndent&quot; style=&quot;MARGIN: 0cm 0cm 6pt&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;这是&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Pocket PC&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;上推荐使用的嵌入式数据库产品，它与&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;SQL Server&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;桌面版之间可以实现良好的数据同步及互操作，目前正式版的最新版本为&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;2.0&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;。在&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;SQL Server 2005 Beta 2&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;测试版中，包含有&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;SQL Server CE 2.0&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;的升级版本&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;SQL Server 2005 Mobile Edition&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;——不过该版本目前只支持&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Pocket PC 2003&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;系统。预计&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;SQL Server Mobile Edition&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;在下一个版本中才能提供对&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Smartphone&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;的支持。&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;h2 style=&quot;MARGIN: 13pt 0cm&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;font size=&quot;3&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;ActiveSync&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 黑体; mso-ascii-font-family: Verdana&quot;&gt;环境搭建&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/h2&gt;&lt;p class=&quot;MsoBodyTextFirstIndent&quot; style=&quot;MARGIN: 0cm 0cm 6pt&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;在完成了上述开发环境的搭建之后，您就可以在&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Visual Studio .NET&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;中开发和调试应用程序，并在设备&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;模拟器中进行部署。但是，如果您还需要进一步执行下述操作，那么请按本节所述继续搭建&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;ActiveSync&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;环境。可能的执行操作包括（但不限于）：&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;p class=&quot;MsoBodyTextFirstIndent&quot; style=&quot;MARGIN: 0cm 0cm 6pt 42pt; TEXT-INDENT: -21pt; mso-list: l0 level1 lfo2; tab-stops: list 42.0pt; mso-char-indent-count: 0&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;FONT-FAMILY: Wingdings; mso-bidi-font-family: Wingdings; mso-fareast-font-family: Wingdings&quot;&gt;&lt;span style=&quot;mso-list: Ignore&quot;&gt;l&lt;span style=&quot;FONT: 7pt &amp;#39;Times New Roman&amp;#39;&quot;&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;向设备&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;模拟器中复制文件&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;p class=&quot;MsoBodyTextFirstIndent&quot; style=&quot;MARGIN: 0cm 0cm 6pt 42pt; TEXT-INDENT: -21pt; mso-list: l0 level1 lfo2; tab-stops: list 42.0pt; mso-char-indent-count: 0&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;FONT-FAMILY: Wingdings; mso-bidi-font-family: Wingdings; mso-fareast-font-family: Wingdings&quot;&gt;&lt;span style=&quot;mso-list: Ignore&quot;&gt;l&lt;span style=&quot;FONT: 7pt &amp;#39;Times New Roman&amp;#39;&quot;&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;从设备&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;模拟器中删除文件&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;p class=&quot;MsoBodyTextFirstIndent&quot; style=&quot;MARGIN: 0cm 0cm 6pt 42pt; TEXT-INDENT: -21pt; mso-list: l0 level1 lfo2; tab-stops: list 42.0pt; mso-char-indent-count: 0&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;FONT-FAMILY: Wingdings; mso-bidi-font-family: Wingdings; mso-fareast-font-family: Wingdings&quot;&gt;&lt;span style=&quot;mso-list: Ignore&quot;&gt;l&lt;span style=&quot;FONT: 7pt &amp;#39;Times New Roman&amp;#39;&quot;&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;与设备&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;模拟器同步数据&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;p class=&quot;MsoBodyTextFirstIndent&quot; style=&quot;MARGIN: 0cm 0cm 6pt 42pt; TEXT-INDENT: -21pt; mso-list: l0 level1 lfo2; tab-stops: list 42.0pt; mso-char-indent-count: 0&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;FONT-FAMILY: Wingdings; mso-bidi-font-family: Wingdings; mso-fareast-font-family: Wingdings&quot;&gt;&lt;span style=&quot;mso-list: Ignore&quot;&gt;l&lt;span style=&quot;FONT: 7pt &amp;#39;Times New Roman&amp;#39;&quot;&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;开发和调试包含&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;RAPI (Remote API)&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;功能的应用&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;p class=&quot;MsoBodyTextFirstIndent&quot; style=&quot;MARGIN: 0cm 0cm 6pt 42pt; TEXT-INDENT: -21pt; mso-list: l0 level1 lfo2; tab-stops: list 42.0pt; mso-char-indent-count: 0&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;FONT-FAMILY: Wingdings; mso-bidi-font-family: Wingdings; mso-fareast-font-family: Wingdings&quot;&gt;&lt;span style=&quot;mso-list: Ignore&quot;&gt;l&lt;span style=&quot;FONT: 7pt &amp;#39;Times New Roman&amp;#39;&quot;&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;……&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;h3 style=&quot;MARGIN: 13pt 0cm&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 黑体; mso-ascii-font-family: Verdana&quot;&gt;安装&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;ActiveSync&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/h3&gt;&lt;p class=&quot;MsoBodyTextFirstIndent&quot; style=&quot;MARGIN: 0cm 0cm 6pt&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;ActiveSync&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;是一款管理&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Windows Mobile&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;设备连接、与&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;PC&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;进行数据同步的工具。如果您开发时使用的是真实设备，则最好事先安装&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;ActiveSync&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;使之与&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;PC&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;机连接。如果您使用的是模拟器，则除了安装&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;ActiveSync&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;以外，还需要安装下述工具。&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;h3 style=&quot;MARGIN: 13pt 0cm&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 黑体; mso-ascii-font-family: Verdana&quot;&gt;安装&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Connect Emulator with ActiveSync&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/h3&gt;&lt;p class=&quot;MsoBodyTextFirstIndent&quot; style=&quot;MARGIN: 0cm 0cm 6pt&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;如果您使用的是模拟器软件，除了安装&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;ActiveSync&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;外，还必须安装&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Connect Emulator with ActiveSync&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;这款工具软件。它将使您可以直接通过&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;ActiveSync&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;连接到模拟器上。&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;h2 style=&quot;MARGIN: 13pt 0cm&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 黑体; mso-ascii-font-family: Verdana&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;3&quot;&gt;辅助工具介绍&lt;/font&gt;&lt;/span&gt;&lt;/h2&gt;&lt;p class=&quot;MsoBodyTextFirstIndent&quot; style=&quot;MARGIN: 0cm 0cm 6pt&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;除了上述基本开发工具以外，在&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Windows Mobile&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;开发社区中还存在着大量的辅助工具，包括应用程序框架、工具、控件等等。其中有一些由于定位准确、制作优良、使用方便，已经成为&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Windows Mobile&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;开发不可或缺的好助手。以下列出其中的一部分，更多的还存在于&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Windows Mobile&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;开发者社区及互联网上，等待着您去发现。&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;h3 style=&quot;MARGIN: 13pt 0cm&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;OpenNETCF.org Smart Device Framework&lt;/font&gt;&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;MsoBodyTextFirstIndent&quot; style=&quot;MARGIN: 0cm 0cm 6pt&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;由几位长年活跃于&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Windows Mobile&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;开发者社区的&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;MVP&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;共同开发的&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;OpenNETCF.org Smart Device Framework (&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;以下简称为&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;SDF)&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;，几天前刚刚获得了&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Pocket PC Magazine&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;评出的&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;2004&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;年度最佳&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;.NET&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;开发框架大奖。熟悉&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;SDF&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;的开发者都会认为，对于这一奖项，&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;OpenNETCF&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;的确当之无愧，因为&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;SDF&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;几乎已经成了&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Windows Mobile&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;开发者不可或缺的工具。他们对&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;.NET CF&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;的不足给出了及时的弥补，在&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;SDF&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;中，您可以找到&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Configuration&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;、&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;XML Serialization&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;、&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt; Notification&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;、&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Interop Services&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;、&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;WSE 2.0&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;等一系列&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;.NET CF&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;当前版本尚未提供的功能，以及诸如&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;ListBoxEx&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;等优秀的控件。更值得一提的是，&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;SDF&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;是一项完全免费的开源项目。这几位&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;MVP&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;为整个&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Windows Mobile&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;开发者社区所做的贡献也许真的无法用金钱来衡量。&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;p class=&quot;MsoBodyTextFirstIndent&quot; style=&quot;MARGIN: 0cm 0cm 6pt&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;下载地址：&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;&lt;a href=&quot;http://www.opennetcf.org/&quot;&gt;http://www.opennetcf.org&lt;/a&gt;&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;。&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;h3 style=&quot;MARGIN: 13pt 0cm&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Windows &lt;st1:place w:st=&quot;on&quot;&gt;Mobile&lt;/st1:place&gt; Developer Power Toys&lt;/font&gt;&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;MsoBodyTextFirstIndent&quot; style=&quot;MARGIN: 0cm 0cm 6pt&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;这是微软继&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Pocket PC/Smartphone 2003 SDK&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;之后为开发人员提供的另一套开发辅助工具集。其中包含不少非常值得一用的优秀工具，如：&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;p class=&quot;MsoBodyTextFirstIndent&quot; style=&quot;MARGIN: 0cm 0cm 6pt 42pt; TEXT-INDENT: -21pt; mso-list: l1 level1 lfo3; tab-stops: list 42.0pt; mso-char-indent-count: 0&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;FONT-FAMILY: Wingdings; mso-bidi-font-family: Wingdings; mso-fareast-font-family: Wingdings&quot;&gt;&lt;span style=&quot;mso-list: Ignore&quot;&gt;l&lt;span style=&quot;FONT: 7pt &amp;#39;Times New Roman&amp;#39;&quot;&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;ActiveSync Remote Display&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;：把连接在&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;PC&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;上的智能设备影像通过&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;PC&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;屏幕放大显示&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;p class=&quot;MsoBodyTextFirstIndent&quot; style=&quot;MARGIN: 0cm 0cm 6pt 42pt; TEXT-INDENT: -21pt; mso-list: l1 level1 lfo3; tab-stops: list 42.0pt; mso-char-indent-count: 0&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;FONT-FAMILY: Wingdings; mso-bidi-font-family: Wingdings; mso-fareast-font-family: Wingdings&quot;&gt;&lt;span style=&quot;mso-list: Ignore&quot;&gt;l&lt;span style=&quot;FONT: 7pt &amp;#39;Times New Roman&amp;#39;&quot;&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;CECopy&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;：以命令行的方式向所连接的智能设备传输文件&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;p class=&quot;MsoBodyTextFirstIndent&quot; style=&quot;MARGIN: 0cm 0cm 6pt 42pt; TEXT-INDENT: -21pt; mso-list: l1 level1 lfo3; tab-stops: list 42.0pt; mso-char-indent-count: 0&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;FONT-FAMILY: Wingdings; mso-bidi-font-family: Wingdings; mso-fareast-font-family: Wingdings&quot;&gt;&lt;span style=&quot;mso-list: Ignore&quot;&gt;l&lt;span style=&quot;FONT: 7pt &amp;#39;Times New Roman&amp;#39;&quot;&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Hopper&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;：用于&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Pocket PC 2003&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;的用户输入压力测试工具&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;p class=&quot;MsoBodyTextFirstIndent&quot; style=&quot;MARGIN: 0cm 0cm 6pt 42pt; TEXT-INDENT: -21pt; mso-list: l1 level1 lfo3; tab-stops: list 42.0pt; mso-char-indent-count: 0&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;FONT-FAMILY: Wingdings; mso-bidi-font-family: Wingdings; mso-fareast-font-family: Wingdings&quot;&gt;&lt;span style=&quot;mso-list: Ignore&quot;&gt;l&lt;span style=&quot;FONT: 7pt &amp;#39;Times New Roman&amp;#39;&quot;&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;PPC Command Shell&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;：用于&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Pocket PC 2003&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;的命令行工具&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;p class=&quot;MsoBodyTextFirstIndent&quot; style=&quot;MARGIN: 0cm 0cm 6pt 42pt; TEXT-INDENT: -21pt; mso-list: l1 level1 lfo3; tab-stops: list 42.0pt; mso-char-indent-count: 0&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;FONT-FAMILY: Wingdings; mso-bidi-font-family: Wingdings; mso-fareast-font-family: Wingdings&quot;&gt;&lt;span style=&quot;mso-list: Ignore&quot;&gt;l&lt;span style=&quot;FONT: 7pt &amp;#39;Times New Roman&amp;#39;&quot;&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;TypeIt&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;：用于&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Smartphone 2003&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;的辅助文字输入工具&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;p class=&quot;MsoBodyTextFirstIndent&quot; style=&quot;MARGIN: 0cm 0cm 6pt 42pt; TEXT-INDENT: -21pt; mso-list: l1 level1 lfo3; tab-stops: list 42.0pt; mso-char-indent-count: 0&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span lang=&quot;EN-US&quot; style=&quot;FONT-FAMILY: Wingdings; mso-bidi-font-family: Wingdings; mso-fareast-font-family: Wingdings&quot;&gt;&lt;span style=&quot;mso-list: Ignore&quot;&gt;l&lt;span style=&quot;FONT: 7pt &amp;#39;Times New Roman&amp;#39;&quot;&gt;         &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;……&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;h3 style=&quot;MARGIN: 13pt 0cm&quot;&gt;&lt;span lang=&quot;EN-US&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;2&quot;&gt;Mobile Application Development Toolkit 2004&lt;/font&gt;&lt;/span&gt;&lt;/h3&gt;&lt;p class=&quot;MsoBodyTextFirstIndent&quot; style=&quot;MARGIN: 0cm 0cm 6pt&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;这是微软近期推出的&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Windows Mobile&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;开发工具及资料集，其中包含上述所有产品及工具，以及一系列相关的文档、教程及参考资料。&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;h2 style=&quot;MARGIN: 13pt 0cm&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 黑体; mso-ascii-font-family: Verdana&quot;&gt;&lt;font face=&quot;Verdana&quot; size=&quot;3&quot;&gt;结束语&lt;/font&gt;&lt;/span&gt;&lt;/h2&gt;&lt;p class=&quot;MsoBodyTextFirstIndent&quot; style=&quot;MARGIN: 0cm 0cm 6pt&quot;&gt;&lt;font face=&quot;Verdana&quot;&gt;&lt;font size=&quot;2&quot;&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;好了，对于如何搭建&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Windows Mobile&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;的开发环境就介绍到这里了。可以肯定地说，随着微软公司支持力度的增加和&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Windows Mobile&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;开发者社区的成熟，&lt;/span&gt;&lt;span lang=&quot;EN-US&quot;&gt;Windows Mobile&lt;/span&gt;&lt;span style=&quot;FONT-FAMILY: 宋体; mso-ascii-font-family: &amp;#39;Times New Roman&amp;#39;; mso-hansi-font-family: &amp;#39;Times New Roman&amp;#39;&quot;&gt;开发将面临越来越有利的良好环境。&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;/div&gt;</description>
  <comments>http://techonly.livejournal.com/15651.html</comments>
  <category>mobile</category>
  <category>windows</category>
  <category>pocketpc</category>
  <category>smartphone</category>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://techonly.livejournal.com/15427.html</guid>
  <pubDate>Thu, 14 Jun 2007 04:45:25 GMT</pubDate>
  <title>25 Ways To Improve Your Site Today</title>
  <link>http://techonly.livejournal.com/15427.html</link>
  <description>From &lt;a href=&quot;http://fadtastic.net/2007/06/10/25-ways-to-improve-your-site-today/&quot;&gt;http://fadtastic.net/2007/06/10/25-ways-to-improve-your-site-today/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Yes, the title may look like this post should be on an amateur blog and that it will be full of references to clip art and animated gifs, but this is serious. I’ve compiled a list of what I think are 25 ways to improve your website in as little time as possible. All can be done in a matter of minutes. Now, a website is hard work and usually there are no quick fixes but this list should provide you with a few pointers to make some updates today. If you like, it can also be used as a basis for a quality check document.&lt;/p&gt;&lt;h2&gt;Usability/Accessibility&lt;/h2&gt;&lt;p&gt;Because it matters. If people can’t use your site, they won’t stay.&lt;/p&gt;&lt;ol&gt;&lt;li&gt;&lt;strong&gt;Navigation: &lt;/strong&gt;Ensure that your navigation is easy to use and consistent. You may be able to use it, but could a newcomer find the information they desire? &lt;li&gt;&lt;strong&gt;Search: &lt;/strong&gt;If you don’t have a search box, then why not? Sometimes navigation isn’t enough. It may not be a 5 minute job to add a custom search facility, but it is extremely quick to add a third party search like &lt;a title=&quot;add Google&amp;#39;s search functionality to your site&quot; href=&quot;http://www.google.com/services/websearch.html&quot;&gt;Google’s&lt;/a&gt;. &lt;li&gt;&lt;strong&gt;Click here:&lt;/strong&gt; Why? Change this phrase everywhere on your site. It doesn’t make sense out of context. The user has to read the whole paragraph (&lt;a title=&quot;why user&amp;#39;s scan read&quot; href=&quot;http://www.useit.com/alertbox/whyscanning.html&quot;&gt;which they probably won’t&lt;/a&gt;) to understand why they should click there. Consider phrases like &lt;em&gt;“Download the profit/loss graph”&lt;/em&gt; or &lt;em&gt;“Listen to the podcast entitled food for thought.” &lt;/em&gt;&lt;li&gt;&lt;strong&gt;Title &amp;amp; Alt Attributes:&lt;/strong&gt; Use them how they are &lt;a title=&quot;Guide to using titles/alts correctly&quot; href=&quot;/2007/04/19/proper-use-of-alt-and-title-attributes/&quot;&gt;supposed to be used&lt;/a&gt;. If you haven’t used any at all, then a quick fix will be to start adding them to navigation and other elements on every page. &lt;li&gt;&lt;strong&gt;General:&lt;/strong&gt; If you’ve got any code snippets that could annoy the user, like resizing browser windows or opening new pages in a new window, then remove them. Just because you like something a particular way, your users may not. Don’t take over their desktop. &lt;/li&gt;&lt;/ol&gt;&lt;h2&gt;Search Engine Optimisation - SEO&lt;/h2&gt;&lt;p&gt;Because you want to be found. (On-page tips only here)&lt;/p&gt;&lt;ol&gt;&lt;li&gt;&lt;strong&gt;Titles:&lt;/strong&gt; Add consistent, relevant but different titles (&lt;em&gt;title&lt;/em&gt; tag) to every page in your site. If you already have titles, check that they are short and describe the content of the page. &lt;li&gt;&lt;strong&gt;Link around:&lt;/strong&gt; Internal links to your pages (I’m thinking from the body copy here) are just as important as external links. Besides the usability gain, you have the unique opportunity of specifying your link and title text. &lt;li&gt;&lt;strong&gt;Strengthen keywords:&lt;/strong&gt; Probably the quickest thing you can do. Highlight some keywords and phrases and add a &lt;em&gt;strong&lt;/em&gt; tag (bold) around them. This shouldn’t be overused but can provide some positive results if used sparingly. &lt;li&gt;&lt;strong&gt;Headers:&lt;/strong&gt; The correct use of headers (in a semantic, logical manner) can produce fantastic results. The H1 tag is the most important - try using some keywords in there. &lt;li&gt;&lt;strong&gt;Overkill:&lt;/strong&gt; It seems whenever I speak to someone about SEO and give them some tips, they go way overboard. This can really &lt;a title=&quot;usability versus seo&quot; href=&quot;/2007/05/09/seo-should-search-engines-matter-in-your-campaign/&quot;&gt;ruin all the hard work you’ve done for the user&lt;/a&gt;. So remember, optimise with the user in mind. And stay away from dodgy SEO stuff - every time you use black-hat SEO, a kitten steps on broken glass. &lt;/li&gt;&lt;/ol&gt;&lt;h2&gt;Design/Development Process&lt;/h2&gt;&lt;p&gt;Design is our passion. Let it show.&lt;/p&gt;&lt;ol&gt;&lt;li&gt;&lt;strong&gt;Images: &lt;/strong&gt;By all means create beautiful images, but don’t forget to optimise them for the web. You may have a quick connection - not everybody does. &lt;li&gt;&lt;strong&gt;Design comes from scratch(pad):&lt;/strong&gt; Don’t necessarily fire up your graphics editor before thinking about the design. It can only take 10 minutes to draw (you know - pencil and paper) various layouts and wireframe the design. Doing this will make you think more about placement of elements and less about the aesthetics. &lt;li&gt;&lt;strong&gt;Contrast/Text-size:&lt;/strong&gt; Ensure that contrast levels and text sizes are ‘acceptable’ - There are no golden figures (although &lt;a title=&quot;Colour contrast tester&quot; href=&quot;http://juicystudio.com/services/colourcontrast.php&quot;&gt;recommendations are available&lt;/a&gt;) to aim for but at least check with other people using different setups. Just because you have perfect 20:20 vision doesn’t mean that anyone can read your site. &lt;li&gt;&lt;strong&gt;Consistency:&lt;/strong&gt; There’s nothing worse (OK - an exaggeration, yes) than a website that doesn’t function consistently. A user can find it hard enough to learn how a website is put together without having to remember all the little quirks and foibles on your site. &lt;li&gt;&lt;strong&gt;Testing:&lt;/strong&gt; Check (or get others to check) the site under as many conditions as possible. Try to do this every time the site has a significant update. It’s worth it as it only takes a minute or two. &lt;/li&gt;&lt;/ol&gt;&lt;h2&gt;Content&lt;/h2&gt;&lt;p&gt;That’s why people visit the site.&lt;/p&gt;&lt;ol&gt;&lt;li&gt;&lt;strong&gt;Text/Whitespace: &lt;/strong&gt;There’s a big trap that often people fall into. Whitespace. How many times have you heard &lt;em&gt;“we need to fill that space and cram the text in a bit more”&lt;/em&gt; ? More text in a single area isn’t a good thing. It can make it harder and less enjoyable to read the content. It you had a shop would you cram as many products in as possible? No. You’d let them have space so they get noticed. Do the same with your text. &lt;li&gt;&lt;strong&gt;Write for your audience:&lt;/strong&gt; Can people understand your text? Think about your audience and reword those confusing sentences. &lt;li&gt;&lt;strong&gt;Corporate Boasting:&lt;/strong&gt; Which is more useful ~ &lt;em&gt;“We provide 200 megaunits of wobble-sprockets to our worldwide, global markets”&lt;/em&gt; ~ or ~ &lt;em&gt;“We can provide a wobble-sprocket to you anywhere in the world.”&lt;/em&gt; Speak to the reader and engage them. Don’t waffle. &lt;li&gt;&lt;strong&gt;Use interest:&lt;/strong&gt; If someone has read an article or item of content, then it is fair to assume that they were interested. Instead of leaving them high-and-dry after an article, point them somewhere related, whether it be another article or a product perhaps. &lt;li&gt;&lt;strong&gt;Objectives:&lt;/strong&gt; When writing content, make a little mental note of what your goal is for the page (e.g. encourage registration) and try to guess what the users goal is (e.g. to get at information.) Match the two (e.g. &lt;em&gt;“to find this information simply sign up”&lt;/em&gt;) and you’re golden. &lt;/li&gt;&lt;/ol&gt;&lt;h2&gt;Off-Site&lt;/h2&gt;&lt;p&gt;Because it’s not all about you.&lt;/p&gt;&lt;ol&gt;&lt;li&gt;&lt;strong&gt;Hang out:&lt;/strong&gt; For reasons surrounding traffic and respect. Go to forums, blogs and portals within your niche and hang out. Offer advice, link up with people and gain respect. Doing this for 10 minutes a day will improve your image and lead to quality, niche-lead traffic. A bonus. Oh, and don’t spam your community. &lt;li&gt;&lt;strong&gt;Learn:&lt;/strong&gt; As well as handing out advice, listen. Whether it be listening to colleagues, competition or potential clients you are bound to learn an awful lot just by witnessing other people’s actions. &lt;li&gt;&lt;strong&gt;Encourage viral promotion:&lt;/strong&gt; Not particularly in a gimmicky-email-newsletter fashion (that takes budget and time) but in a social fashion. Tell your friends and colleagues (and clients if relevant) something unique about you, your company or website and chances are they’ll pass it on. 5 minutes of blabbering could lead to heaps of traffic. &lt;li&gt;&lt;strong&gt;Be yourself:&lt;/strong&gt; When interacting online, don’t conform to internet stereotypes - just be yourself. Doing this will mean that you are natural when interacting online and more likely to take a similar approach as you would offline. So, take your offline business ways online. &lt;li&gt;&lt;strong&gt;Spam:&lt;/strong&gt; As in &lt;em&gt;don’t spam&lt;/em&gt;. Every time you spam, you are adding disrespect to your own company/site. It’s the real-world equivalent of pushing a leaflet into a potential customer’s mouth. &lt;/li&gt;&lt;/ol&gt;&lt;p&gt;And there we go. I hope this list is useful and has shown you how easy it is to improve various aspects of your website and its marketing. This isn’t exhaustive by any means - as I said earlier it takes effort and time to really get your site near-perfect. Evolution is the key: tweak, feedback, measure and repeat. Oh, and before you go looking, no, I don’t always practice what I preach!&lt;/p&gt;</description>
  <comments>http://techonly.livejournal.com/15427.html</comments>
  <category>site</category>
  <category>website</category>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://techonly.livejournal.com/15178.html</guid>
  <pubDate>Wed, 13 Jun 2007 14:01:24 GMT</pubDate>
  <title>~/.vimrc</title>
  <link>http://techonly.livejournal.com/15178.html</link>
  <description>set ruler&lt;br /&gt;set autoindent&lt;br /&gt;set smartindent&lt;br /&gt;set tabstop=4&lt;br /&gt;set shiftwidth=4&lt;br /&gt;set showmatch&lt;br /&gt;set nohls&lt;br /&gt;set incsearch&lt;br /&gt;&lt;br /&gt;Type :help options within vim to get a complete list of options.</description>
  <comments>http://techonly.livejournal.com/15178.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://techonly.livejournal.com/15001.html</guid>
  <pubDate>Wed, 13 Jun 2007 13:20:31 GMT</pubDate>
  <title>It seems that ubuntu 7.04 doesn&apos;t have ncurses lib</title>
  <link>http://techonly.livejournal.com/15001.html</link>
  <description>Just write a simple test program,&lt;br /&gt;&lt;br /&gt;#include &lt;div class=&apos;ljparseerror&apos;&gt;[&lt;b&gt;Error:&lt;/b&gt; Irreparable invalid markup (&apos;&amp;lt;ncurses.h&amp;gt;&apos;) in entry.  Owner must fix manually.  Raw contents below.]&lt;br /&gt;&lt;br /&gt;&lt;div style=&quot;width: 95%; overflow: auto&quot;&gt;Just write a simple test program,&lt;br /&gt;&lt;br /&gt;#include &amp;lt;ncurses.h&amp;gt;&lt;br /&gt;&lt;br /&gt;int main()&lt;br /&gt;{	&lt;br /&gt;	initscr();			/* Start curses mode 		  */&lt;br /&gt;	printw(&amp;quot;Hello World !!!&amp;quot;);	/* Print Hello World		  */&lt;br /&gt;	refresh();			/* Print it on to the real screen */&lt;br /&gt;	getch();			/* Wait for user input */&lt;br /&gt;	endwin();			/* End curses mode		  */&lt;br /&gt;&lt;br /&gt;	return 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;However,&lt;br /&gt;user@localhost:~/progs$ gcc test.c -lncurses&lt;br /&gt;test.c:1:21: error: ncurses.h: No such file or directory&lt;br /&gt;&lt;br /&gt;I tried apt-get to install ncurses, but failed.&lt;br /&gt;user@localhost:~/progs$ sudo apt-get install ncurses&lt;br /&gt;Password:&lt;br /&gt;Reading package lists... Done&lt;br /&gt;Building dependency tree       &lt;br /&gt;Reading state information... Done&lt;br /&gt;Package ncurses is not available, but is referred to by another package.&lt;br /&gt;This may mean that the package is missing, has been obsoleted, or&lt;br /&gt;is only available from another source&lt;br /&gt;E: Package ncurses has no installation candidate&lt;br /&gt;&lt;br /&gt;So I manually apt-get installed the packages listed here(http://packages.ubuntu.com/hoary/source/ncurses) one by one. Now I can compile my ncurses programs.&lt;/div&gt;&lt;/div&gt;</description>
  <comments>http://techonly.livejournal.com/15001.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://techonly.livejournal.com/14755.html</guid>
  <pubDate>Wed, 13 Jun 2007 07:56:35 GMT</pubDate>
  <title>Starting Ncurses</title>
  <link>http://techonly.livejournal.com/14755.html</link>
  <description>History:&lt;br /&gt;termcap -&amp;gt; terminfo -&amp;gt; curses -&amp;gt; ncurses&lt;br /&gt;&lt;br /&gt;Terminal Capability&lt;br /&gt;Terminal Info&lt;br /&gt;Cursor Optimization&lt;br /&gt;New curses&lt;br /&gt;&lt;br /&gt;In short, NCURSES is a library of functions that manages an application&apos;s display on character-cell terminals.&lt;br /&gt;&lt;br /&gt;Document Download: NCURSES Programming HOWTO&lt;br /&gt;&lt;a href=&quot;http://www.ibiblio.org/pub/Linux/docs/HOWTO/other-formats/html/NCURSES-Programming-HOWTO-html.tar.gz&quot;&gt;http://www.ibiblio.org/pub/Linux/docs/HOWTO/other-formats/html/NCURSES-Programming-HOWTO-html.tar.gz&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;http://tldp.org/HOWTO/NCURSES-Programming-HOWTO/&quot;&gt;http://tldp.org/HOWTO/NCURSES-Programming-HOWTO/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Another tutorial: Writing Programs with NCURSES&lt;br /&gt;&lt;a href=&quot;http://web.cs.mun.ca/~rod/ncurses/ncurses.html&quot;&gt;http://web.cs.mun.ca/~rod/ncurses/ncurses.html&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;http://invisible-island.net/ncurses/ncurses-intro.html&quot;&gt;http://invisible-island.net/ncurses/ncurses-intro.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;A Chinese Guy dedicated to ncurses&lt;br /&gt;&lt;a href=&quot;http://blog.csdn.net/byronm/&quot;&gt;http://blog.csdn.net/byronm/&lt;/a&gt;</description>
  <comments>http://techonly.livejournal.com/14755.html</comments>
  <category>ncurses</category>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://techonly.livejournal.com/14402.html</guid>
  <pubDate>Wed, 13 Jun 2007 06:20:17 GMT</pubDate>
  <title>试试这个windows客户端的中文支持</title>
  <link>http://techonly.livejournal.com/14402.html</link>
  <description>如题。</description>
  <comments>http://techonly.livejournal.com/14402.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://techonly.livejournal.com/14289.html</guid>
  <pubDate>Wed, 13 Jun 2007 06:05:24 GMT</pubDate>
  <title>Try LiveJournal Windows Client</title>
  <link>http://techonly.livejournal.com/14289.html</link>
  <description>Semagic 1.7.0.5U&lt;br /&gt;&lt;a href=&quot;http://semagic.sourceforge.net/index.html&quot;&gt;http://semagic.sourceforge.net/index.html&lt;/a&gt;</description>
  <comments>http://techonly.livejournal.com/14289.html</comments>
  <category>windows</category>
  <category>livejournal</category>
  <category>client</category>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://techonly.livejournal.com/14041.html</guid>
  <pubDate>Tue, 12 Jun 2007 23:51:43 GMT</pubDate>
  <title>在 Ubuntu Linux 上安装 Java 和 Eclipse</title>
  <link>http://techonly.livejournal.com/14041.html</link>
  <description>&lt;a href=&quot;http://blog.csdn.net/holy_phoenix/archive/2006/09/04/1176871.aspx&quot;&gt;http://blog.csdn.net/holy_phoenix/archive/2006/09/04/1176871.aspx&lt;/a&gt;</description>
  <comments>http://techonly.livejournal.com/14041.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://techonly.livejournal.com/13703.html</guid>
  <pubDate>Tue, 12 Jun 2007 23:44:55 GMT</pubDate>
  <title>Livejournal client</title>
  <link>http://techonly.livejournal.com/13703.html</link>
  <description>For GNOME:&lt;br /&gt;drivel&lt;br /&gt;&lt;a href=&quot;http://www.dropline.net/drivel/&quot;&gt;http://www.dropline.net/drivel/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;For KDE:&lt;br /&gt;ljKlient&lt;br /&gt;&lt;a href=&quot;http://ljklient.sourceforge.net/&quot;&gt;http://ljklient.sourceforge.net/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;It seems ljKlient is much better than drivel in regard to many functions, such as Tag, and friend list.</description>
  <comments>http://techonly.livejournal.com/13703.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://techonly.livejournal.com/13466.html</guid>
  <pubDate>Thu, 22 Mar 2007 07:00:28 GMT</pubDate>
  <title>locale详解(zz)</title>
  <link>http://techonly.livejournal.com/13466.html</link>
  <description>locale 是国际化与本土化过程中的一个非常重要的概念，个人认为，对于中文用户来说，通常会涉及到的国际化或者本土化，大致包含三个方面：看中文，写中文，与 window中文系统的兼容和通信。从实际经验上看来，locale的设定与看中文关系不大，但是与写中文，及window分区的挂载方式有很密切的关系。本人认为就像一个纯英文的Windows能够浏览中文，日文或者意大利文网页一样，你不需要设定locale就可以看中文。那么，为什么要设定 locale呢？什么时候会用到locale呢？&lt;br /&gt;&lt;br /&gt;Tags: locale 设定 原因 解释&lt;br /&gt;&lt;br /&gt;一、为什么要设定locale 正如前面我所讲的，设定locale与你能否浏览中文的网页没有直接的关系，即便你把locale设置成en_US.ISO-8859-1这样一个标准的英文locale你照样可以浏览中文的网页，只要你的系统里面有相应的字符集（这个都不一定需要）和合适的字体（如simsun），浏览器就可以把网页翻译成中文给你看。具体的过程是网络把网页传送到你的机器上之后，浏览器会判断相应的编码的字符集，根据网页采用的字符集，去字体库里面找合适的字体，然后由文字渲染工具把相应的文字在屏幕上显示出来。&lt;br /&gt;&lt;br /&gt;在下文本人会偶尔把字符集比喻成密码本，个人觉得对于一些东西比较容易理解，假如你不习惯的话，把全文copy到任何文本编辑器，用字符集替换密码本即可。&lt;br /&gt;&lt;br /&gt;那有时候网页显示乱码或者都是方框是怎么回事呢？个人认为，显示乱码是因为设定的字符集不对(或者没有相应的字符集)，例如网页是用UTF-8编码的，你非要用GB2312去看，而系统根据GB2312去找字体，然后在屏幕上显示，当然是一堆的乱码，也就是说你用一个错误的密码本去翻译发给你的电报，当然内容那叫一个乱；至于有些时候浏览的网页能显示一部分汉字，但有很多的地方是方框，能够显示汉字说明浏览器已经正确的判断出了网页的编码，并在字体库里面找到了相应的文字，但是并不是每个字体库都包含某个字符集全部的字体的缘故，有些时候会显示不完全，找一个比较全的支持较多字符集的字体就可以了。&lt;br /&gt;&lt;br /&gt;既然我能够浏览中文网页，那为什么我还要设定locale呢？&lt;br /&gt;&lt;br /&gt;其实你有没有想过这么一个问题，为什么gentoo官方论坛上中文论坛的网页是用UTF-8编码的（虽然大家一直强烈建议用GB2312编码），但是新浪网就是用GB2312编码的呢？而Xorg的官方网页竟然是ISO-8859-15编码的，我没有设定这个locale怎么一样的能浏览呢？这个问题就像是你有所有的密码本，不论某个网站是用什么字符集编码的，你都可以用你手里的密码本把他们翻译过来，但问题是虽然你能浏览中文网页，但是在整个操作系统里面流动的还是英文字符。所以，就像你能听懂英语，也能听懂中文。 最根本的问题是：你不可以写中文。&lt;br /&gt;&lt;br /&gt;当你决定要写什么东西的时候，首先要决定的一件事情是用那种语言，对于计算机来说就是你要是用哪一种字符集，你就必须告诉你的linux系统，你想用那一本密码本去写你想要写的东西。知道为什么需要用GB2312字符集去浏览新浪了吧，因为新浪的网页是用GB2312写的。&lt;br /&gt;&lt;br /&gt;为了让你的Linux能够输入中文，就需要把系统的locale设定成中文的(严格说来是locale中的语言类别LC_CTYPE )，例如zh_CN.GB2312、zh_CN.GB18030或者zh_CN.UTF-8。很多人都不明白这些古里古怪的表达方式。这个外星表达式规定了什么东西呢？这个问题稍后详述，现在只需要知道，这是locale的表达方式就可以了。&lt;br /&gt;&lt;br /&gt;二、到底什么是locale？ locale这个单词中文翻译成地区或者地域，其实这个单词包含的意义要宽泛很多。Locale是根据计算机用户所使用的语言，所在国家或者地区，以及当地的文化传统所定义的一个软件运行时的语言环境。&lt;br /&gt;&lt;br /&gt;这个用户环境可以按照所涉及到的文化传统的各个方面分成几个大类，通常包括用户所使用的语言符号及其分类(LC_CTYPE)，数字 (LC_NUMERIC)，比较和排序习惯(LC_COLLATE)，时间显示格式(LC_TIME)，货币单位(LC_MONETARY)，信息主要是提示信息,错误信息, 状态信息, 标题, 标签, 按钮和菜单等(LC_MESSAGES)，姓名书写方式(LC_NAME)，地址书写方式(LC_ADDRESS)，电话号码书写方式 (LC_TELEPHONE)，度量衡表达方式(LC_MEASUREMENT)，默认纸张尺寸大小(LC_PAPER)和locale对自身包含信息的概述(LC_IDENTIFICATION)。&lt;br /&gt;&lt;br /&gt;所以说，locale就是某一个地域内的人们的语言习惯和文化传统和生活习惯。一个地区的locale就是根据这几大类的习惯定义的，这些locale定义文件放在/usr /i18n/locales目录下面，例如en_US, zh_CN and de_DE@euro都是locale的定义文件，这些文件都是用文本格式书写的，你可以用写字板打开，看看里边的内容，当然出了有限的注释以外，大部分东西可能你都看不懂，因为是用的Unicode的字符索引方式。&lt;br /&gt;&lt;br /&gt;对于de_DE@euro的一点说明，@后边是修正项，也就是说你可以看到两个德国的locale： /usr /i18n/locales/de_DE@euro /usr /i18n/locales/de_DE 打开这两个locale定义，你就会知道它们的差别在于de_DE@euro使用的是欧洲的排序、比较和缩进习惯，而de_DE用的是德国的标准习惯。&lt;br /&gt;&lt;br /&gt;上面我们说到了zh_CN.GB18030的前半部分，后半部分是什么呢？大部分Linux用户都知道是系统采用的字符集。&lt;br /&gt;&lt;br /&gt;三、什么是字符集？字符集就是字符，尤其是非英语字符在系统内的编码方式，也就是通常所说的内码，所有的字符集都放在/usr /i18n/charmaps，所有的字符集也都是用Unicode编号索引的。Unicode用统一的编号来索引目前已知的全部的符号。而字符集则是这些符号的编码方式，或者说是在网络传输，计算机内部通信的时候，对于不同字符的表达方式，Unicode是一个静态的概念，字符集是一个动态的概念，是每一个字符传递或传输的具体形式。就像 Unicode编号U59D0是代表姐姐的“姐”字，但是具体的这个字是用两个字节表示，三个字节，还是四个字节表示，是字符集的问题。例如：UTF-8 字符集就是目前流行的对字符的编码方式，UTF-8用一个字节表示常用的拉丁字母，用两个字节表示常用的符号，包括常用的中文字符，用三个表示不常用的字符，用四个字节表示其他的古灵精怪的字符。而GB2312字符集就是用两个字节表示所有的字符。需要提到一点的是Unicode除了用编号索引全部字符以外，本身是用四个字节存储全部字符，这一点在谈到挂载windows分区的时候是非常重要的一个概念。所以说你也可以把Unicode看作是一种字符集（我不知道它和UTF-32的关系，反正UTF-32就是用四个字节表示所有的字符的），但是这样表述符号是非常浪费资源的，因为在计算机世界绝大部分时候用到的是一个字节就可以搞定的 26个字母而已。所以才会有UTF-8，UTF-16等等，要不然大同世界多好，省了这许多麻烦。&lt;br /&gt;&lt;br /&gt;四、zh_CN.GB2312到底是在说什么？ Locale 是软件在运行时的语言环境, 它包括语言(Language), 地域 (Territory) 和字符集(Codeset)。一个locale的书写格式为: 语言[_地域[.字符集]]. 所以说呢，locale总是和一定的字符集相联系的。下面举几个例子：&lt;br /&gt;&lt;br /&gt;1、我说中文，身处中华人民共和国，使用国标2312字符集来表达字符。 zh_CN.GB2312＝中文_中华人民共和国＋国标2312字符集。&lt;br /&gt;&lt;br /&gt;2、我说中文，身处中华人民共和国，使用国标18030字符集来表达字符。 zh_CN.GB18030＝中文_中华人民共和国＋国标18030字符集。&lt;br /&gt;&lt;br /&gt;3、我说中文，身处中华人民共和国台湾省，使用国标Big5字符集来表达字符。 zh_TW.BIG5=中文_台湾.大五码字符集&lt;br /&gt;&lt;br /&gt;4、我说英文，身处大不列颠，使用ISO-8859-1字符集来表达字符。 en_GB.ISO-8859-1=英文_大不列颠.ISO-8859-1字符集&lt;br /&gt;&lt;br /&gt;5、我说德语，身处德国，使用UTF-8字符集，习惯了欧洲风格。 de_DE.UTF-8@euro＝德语_德国.UTF-8字符集@按照欧洲习惯加以修正&lt;br /&gt;&lt;br /&gt;注意不是de_DE@euro.UTF-8，所以完全的locale表达方式是 [语言[_地域][.字符集] [@修正值]&lt;br /&gt;&lt;br /&gt;生成的locale放在/usr b/locale/目录中，并且每个locale都对应一个文件夹，也就是说创建了de_DE@euro.UTF-8 locale之后，就生成/usr b/locale/de_DE@euro.UTF-8/目录，里面是具体的每个locale的内容。&lt;br /&gt;&lt;br /&gt;五、怎样去自定义locale 在gentoo生成locale还是很容易的，首先要在USE里面加入userlocales支持，然后编辑locales.build文件，这个文件用来指示glibc生成locale文件。 很多人不明白每一个条目是什么意思。 其实根据上面的说明现在应该很明确了。&lt;br /&gt;&lt;br /&gt;File: /etc/locales.build en_US/ISO-8859-1 en_US.UTF-8/UTF-8&lt;br /&gt;&lt;br /&gt;zh_CN/GB18030 zh_CN.GBK/GBK zh_CN.GB2312/GB2312 zh_CN.UTF-8/UTF-8&lt;br /&gt;&lt;br /&gt;上面是我的locales.build文件，依次的说明是这样的：&lt;br /&gt;&lt;br /&gt;en_US/ISO-8859-1：生成名为en_US的locale，采用ISO-8859-1字符集，并且把这个locale作为英文_美国locale类的默认值，其实它和en_US.ISO-8859-1/ISO-8859-1没有任何区别。&lt;br /&gt;&lt;br /&gt;en_US.UTF-8/UTF-8：生成名为en_US.UTF-8的locale，采用UTF-8字符集。&lt;br /&gt;&lt;br /&gt;zh_CN/GB18030：生成名为zh_CN的locale，采用GB18030字符集，并且把这个locale作为中文_中国locale类的默认值，其实它和zh_CN.GB18030/GB18030没有任何区别。&lt;br /&gt;&lt;br /&gt;zh_CN.GBK/GBK：生成名为zh_CN.GBK的locale，采用GBK字符集。 zh_CN.GB2312/GB2312：生成名为zh_CN.GB2312的locale，采用GB2312字符集。 zh_CN.UTF-8/UTF-8：生成名为zh_CN.UTF-8的locale，采用UTF-8字符集。&lt;br /&gt;&lt;br /&gt;关于默认locale，默认locale可以简写成en_US或者zh_CN的形式，只是为了表达简单而已没有特别的意义。&lt;br /&gt;&lt;br /&gt;Gentoo在locale定义的时候掩盖了一些东西，也就是locale的生成工具：localedef。在编译完glibc之后你可以用这个localedef 再补充一些locale，就会更加理解locale了。具体的可以看 localedef 的manpage。&lt;br /&gt;&lt;br /&gt;$localedef -f 字符集 -i locale定义文件 生成的locale的名称 例如 $localedef -f UTF-8 -i zh_CN zh_CN.UTF-8&lt;br /&gt;&lt;br /&gt;上面的定义方法和在locales.build中设定zh_CN.UTF-8/UTF-8的结果是一样一样的。&lt;br /&gt;&lt;br /&gt;六、locale的五脏六腑&lt;br /&gt;&lt;br /&gt;刚刚生成了几个locale，但是为了让它们生效，必须告诉Linux系统使用那(几)个locale。这就需要对locale的内部机制有一点点的了解。在前面我已经提到过，locale把按照所涉及到的文化传统的各个方面分成12个大类，这12个大类分别是： 1、语言符号及其分类(LC_CTYPE) 2、数字(LC_NUMERIC) 3、比较和排序习惯(LC_COLLATE) 4、时间显示格式(LC_TIME) 5、货币单位(LC_MONETARY) 6、信息主要是提示信息,错误信息, 状态信息, 标题, 标签, 按钮和菜单等(LC_MESSAGES) 7、姓名书写方式(LC_NAME) 8、地址书写方式(LC_ADDRESS) 9、电话号码书写方式(LC_TELEPHONE) 10、度量衡表达方式(LC_MEASUREMENT) 11、默认纸张尺寸大小(LC_PAPER) 12、对locale自身包含信息的概述(LC_IDENTIFICATION)。&lt;br /&gt;&lt;br /&gt;其中，与中文输入关系最密切的就是 LC_CTYPE， LC_CTYPE 规定了系统内有效的字符以及这些字符的分类，诸如什么是大写字母，小写字母，大小写转换，标点符号、可打印字符和其他的字符属性等方面。而locale定义zh_CN中最最重要的一项就是定义了汉字(Class “hanzi”)这一个大类，当然也是用Unicode描述的，这就让中文字符在Linux系统中成为合法的有效字符，而且不论它们是用什么字符集编码的。&lt;br /&gt;&lt;br /&gt;LC_CTYPE % This is a copy of the &quot;i18n&quot; LC_CTYPE with the following modifications: - Additional classes: hanzi&lt;br /&gt;&lt;br /&gt;copy &quot;i18n&quot;&lt;br /&gt;&lt;br /&gt;class &quot;hanzi&quot;; / % ..;/ ..;/ ;;;;;;;;/ ;;;;;;;;/ ;;;; END LC_CTYPE&lt;br /&gt;&lt;br /&gt;在en_US的locale定义中，并没有定义汉字，所以汉字不是有效字符。所以如果要输入中文必须使用支持中文的locale，也就是zh_XX，如zh_CN，zh_TW，zh_HK等等。&lt;br /&gt;&lt;br /&gt;另外非常重要的一点就是这些分类是彼此独立的，也就是说LC_CTYPE，LC_COLLATE和 LC_MESSAGES等等分类彼此之间是独立的，可以根据用户的需要设定成不同的值。这一点对很多用户是有利的，甚至是必须的。例如，我就需要一个能够输入中文的英文环境，所以我可以把LC_CTYPE设定成zh_CN.GB18030，而其他所有的项都是en_US.UTF-8。&lt;br /&gt;&lt;br /&gt;七、怎样设定locale呢？&lt;br /&gt;&lt;br /&gt;设定locale就是设定12大类的locale分类属性，即 12个LC_*。除了这12个变量可以设定以外，为了简便起见，还有两个变量：LC_ALL和LANG。它们之间有一个优先级的关系： LC_ALL&amp;gt;LC_*&amp;gt;LANG 可以这么说，LC_ALL是最上级设定或者强制设定，而LANG是默认设定值。 1、如果你设定了LC_ALL＝zh_CN.UTF-8，那么不管LC_*和LANG设定成什么值，它们都会被强制服从LC_ALL的设定，成为 zh_CN.UTF-8。 2、假如你设定了LANG＝zh_CN.UTF-8，而其他的LC_*=en_US.UTF-8，并且没有设定LC_ALL的话，那么系统的locale 设定以LC_*=en_US.UTF-8。 3、假如你设定了LANG＝zh_CN.UTF-8，而其他的LC_*，和LC_ALL均未设定的话，系统会将LC_*设定成默认值，也就是LANG的值 zh_CN.UTF-8 。 4、假如你设定了LANG＝zh_CN.UTF-8，而其他的LC_CTYPE=en_US.UTF-8，其他的LC_*，和LC_ALL均未设定的话，那么系统的locale设定将是：LC_CTYPE=en_US.UTF-8，其余的 LC_COLLATE，LC_MESSAGES等等均会采用默认值，也就是LANG的值，也就是LC_COLLATE＝LC_MESSAGES＝……＝ LC_PAPER＝LANG＝zh_CN.UTF-8。&lt;br /&gt;&lt;br /&gt;所以，locale是这样设定的： 1、如果你需要一个纯中文的系统的话，设定LC_ALL= zh_CN.XXXX，或者LANG= zh_CN.XXXX都可以，当然你可以两个都设定，但正如上面所讲，LC_ALL的值将覆盖所有其他的locale设定，不要作无用功。 2、如果你只想要一个可以输入中文的环境，而保持菜单、标题，系统信息等等为英文界面，那么只需要设定LC_CTYPE＝zh_CN.XXXX，LANG = en_US.XXXX就可以了。这样LC_CTYPE＝zh_CN.XXXX，而LC_COLLATE＝LC_MESSAGES＝……＝ LC_PAPER＝LANG＝en_US.XXXX。 3、假如你高兴的话，可以把12个LC_*一一设定成你需要的值，打造一个古灵精怪的系统： LC_CTYPE＝zh_CN.</description>
  <comments>http://techonly.livejournal.com/13466.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://techonly.livejournal.com/13252.html</guid>
  <pubDate>Fri, 22 Sep 2006 05:09:50 GMT</pubDate>
  <title>resolve wireless connection</title>
  <link>http://techonly.livejournal.com/13252.html</link>
  <description>1.At first got the warning message when dmesg&lt;br /&gt;&lt;br /&gt;ieee80211_crypt: registered algorithm &apos;NULL&apos;&lt;br /&gt;ieee80211: 802.11 data/management/control stack, git-1.1.7&lt;br /&gt;ieee80211: Copyright (C) 2004-2005 Intel Corporation &amp;lt;jketreno@linux.intel.com&amp;gt;&lt;br /&gt;ipw2100: Intel(R) PRO/Wireless 2100 Network Driver, git-1.2.2&lt;br /&gt;ipw2100: Copyright(c) 2003-2006 Intel Corporation&lt;br /&gt;ACPI: PCI Interrupt 0000:02:03.0[A] -&amp;gt; Link [LNKB] -&amp;gt; GSI 5 (level, low) -&amp;gt; IRQ 5&lt;br /&gt;ipw2100: Detected Intel PRO/Wireless 2100 Network Connection&lt;br /&gt;ipw2100: eth1: Firmware &apos;ipw2100-1.3.fw&apos; not available or load failed.&lt;br /&gt;ipw2100: eth1: ipw2100_get_firmware failed: -2&lt;br /&gt;ipw2100: eth1: Failed to power on the adapter.&lt;br /&gt;ipw2100: eth1: Failed to start the firmware.&lt;br /&gt;ipw2100Error calling register_netdev.&lt;br /&gt;ACPI: PCI interrupt for device 0000:02:03.0 disabled&lt;br /&gt;ipw2100: probe of 0000:02:03.0 failed with error -5&lt;br /&gt;&lt;br /&gt;2.Check &lt;a href=&quot;http://ipw2100.sourceforge.net/#requirements&quot;&gt;here&lt;/a&gt; with my CONFIGURATION. &lt;br /&gt;&lt;br /&gt;	1) Linux kernel satisfies.(That need some kernel tricky settings)&lt;br /&gt;	2) Download the newest Wireless Extensions and Tools(newest recommended in case some weird situation), i.e. iwconfig, iwevent, iwgetid, iwlist, iwpriv and iwspy.&lt;br /&gt;	3) I found I&apos;ve already got the IPW2100 driver under /lib/modules/2.6.17.1/kernel/drivers/net/wireless/. Maybe they were generated while I compiled this new kernel. If not, download it from &lt;a href=&quot;http://ipw2100.sourceforge.net/#downloads&quot;&gt;here&lt;/a&gt;.&lt;br /&gt;	4) Download the v1.3 IPW2100 binary firmware image from &lt;a href=&quot;http://ipw2100.sourceforge.net/firmware.php&quot;&gt;here&lt;/a&gt; and extract them into /lib/firmware. &lt;br /&gt;	And, *** Don&apos;t forget to add /usr/local/lib/ to /etc/ld.so.conf, and run ldconfig as root. ***&lt;br /&gt;&lt;br /&gt;3.OKey! Now execute iwconfig and iw*** to configure the wireless connection.&lt;br /&gt;This is the output of iwconfig&lt;br /&gt;[root@localhost ~]# iwconfig&lt;br /&gt;lo        no wireless extensions.&lt;br /&gt;&lt;br /&gt;eth0      no wireless extensions.&lt;br /&gt;&lt;br /&gt;eth1      unassociated  ESSID:off/any  Nickname:&quot;ipw2100&quot;&lt;br /&gt;          Mode:Managed  Channel=0  Access Point: Not-Associated&lt;br /&gt;          Bit Rate=0 kb/s   Tx-Power:16 dBm&lt;br /&gt;          Retry min limit:7   RTS thr:off   Fragment thr:off&lt;br /&gt;          Encryption key:off&lt;br /&gt;          Power Management:off&lt;br /&gt;          Link Quality:0  Signal level:0  Noise level:0&lt;br /&gt;          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0&lt;br /&gt;          Tx excessive retries:0  Invalid misc:0   Missed beacon:0&lt;br /&gt;&lt;br /&gt;ppp0      no wireless extensions.</description>
  <comments>http://techonly.livejournal.com/13252.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://techonly.livejournal.com/12908.html</guid>
  <pubDate>Wed, 20 Sep 2006 15:17:40 GMT</pubDate>
  <title>网通电信七宗罪！</title>
  <link>http://techonly.livejournal.com/12908.html</link>
  <description>【摘要】中国可生气的事数不胜数，不到忍无可忍，谁也不愿动肝火，到今天为止，我投诉互联互通问题刚好满一年，在此正式宣布投降，本文列举的两大电信运营商的七大罪状全是我亲身经历，作为庶民，我很生气，但后果一点也不严重，因为我连选择的余地都没有，当你厌倦了一个运营商想选择另一个时，却发现他们位于长江的另一边。 &lt;br /&gt;　　中国可生气的事数不胜数，不到忍无可忍，谁也不愿动肝火，到今天为止，我投诉互联互通问题刚好满一年，在此正式宣布投降，本文列举的两大电信运营商的七大罪状全是我亲身经历，作为庶民，我很生气，但后果一点也不严重，因为我连选择的余地都没有，当你厌倦了一个运营商想选择另一个时，却发现他们位于长江的另一边。&lt;br /&gt;　　&lt;br /&gt;　　&lt;br /&gt;　　1. 互联不互通&lt;br /&gt;　　&lt;br /&gt;　　这个问题之经典，随便在长江南北找个人问问都知道，首先，这不是技术问题，如果说中国的软件和芯片行业比国外弱我信，互联网方面的技术，全球基本是一致的，说白了，诞生于上世纪中页的互联网从来都不是一个技术含量很高的东西，两大运营商有足够的能力将这件事做好，互联互通问题就象两个人对着头挖隧道，他们宁肯挖成两条隧道，也不肯在中间对接，最终，中国铺设了全世界最庞大的光缆系统，但这些光缆却没有给我们贡献多少实用的带宽，你打 10060 或 10000 抱怨网速，他们会信誓旦旦地说网速没有问题，你去桃花源找部电影看看慢吗，你访问新浪看看慢吗，诸如此类，在很多人看来，上网就是去看盗版电影或者浏览八卦新闻，但互联网上有无数的应用，很多应用需要全程带宽的支持，如果某个接点出现瓶颈，你没有权利说那是别的运营商的问题，即使是，你也有义务去协调，事实上互联互通问题已经存在了四年的时间，这四年，各大门户自己搞了负载均衡，下载站点开设了镜像，网吧开通了双路，倒霉的是家庭和企业的宽带用户，在这方面，你几乎没有任何可以做的事，网通和电信是不受理互联互通投诉的，他们会将你的问题混淆，转移，实在躲不过，就推给北京的高层。&lt;br /&gt;　　&lt;br /&gt;　　关于互联互通问题在中国已经严重到什么程度，我举一个例子，我的公司在青岛和广州分别有多台服务器托管在电信和网通的机房，其中青岛的服务器使用双 IP，一个 IP 属于网通，另一个属于电信，使用青岛网通的 IP PING 广州电信的服务器，时延是 700ms，改用电信的 PING，时延马上缩短为 10ms 以下；现在，我用青岛网通的 IP PING 同一个机房中使用电信 IP 的服务器，时延是 600ms，同一个机房的两台服务器位于同一个机架，它们之间的物理距离只有王家卫的 0.01 公分。另一个例子，为了远程登陆我广州的服务器，我需要首先登陆位于澳门的另一台服务器，再跳到广州，这样连接的速度，是直接连接的 20 倍。关于互联互通，网通的一个客服曾说过一句很经典的话，“陈天桥比你厉害吧，他的网络游戏公司也得接受这个现实。”&lt;br /&gt;　　&lt;br /&gt;　　&lt;br /&gt;　　2. 成为瓶颈的国际端口&lt;br /&gt;　　&lt;br /&gt;　　中国是鼓励老百姓老老实实待在家里，没事不要出门的，但互联网是一张全球的网，理论上没有地域概念，在国际互联网中，你没有办法独善其身。从 2005 年以来，我一直向网通抱怨国际端口瓶颈问题，但网通一直都在热火朝天地忙他们的宽带中国，在网通的一些视频点播网站，你差不多能用一两个小时就下载一部大片，却无法在同样的时间内从国外的服务器上收下一封几十K的邮件，同时，我的用户在国外出差的时候，半夜给我打电话，抱怨无法收邮件，而他们用远程技术登陆他们的办公室网络的时候，速度只有几百字节，相当于九十年代中期拨号的速度，网通的客服对这个问题的解释永远是爱国的，那就是，肯定是国外的网络出了问题，在网通看来，国外大概落后得不得了，为了证明国际端口的瓶颈问题，我特地在电信和网通的两个网络上做了一个测试，众所周知，电信的国际端口要快很多，我从广州向澳门（澳门是中国领土不可分割的一部分）做了一个 tracert，发现数据包先是传到北京，再从北京传到澳门，其中最大的一个越点时延是 4ms；同时，从青岛向澳门同一台服务器做了另一个 racert 测试，数据包也是先到达北京，再去澳门，而在这个 trace 中，最大的一个时延为 890 ms，这个延迟所在的越点正好位于北京和澳门之间。&lt;br /&gt;　　&lt;br /&gt;　　&lt;br /&gt;　　3. 关公战秦琼&lt;br /&gt;　　&lt;br /&gt;　　让多个运营商展开竞争，以提高电信服务质量，是当初电信拆分的初衷，这没有错，问题是，既然要竞争，为什么不放在同一个地区短兵交接，却让他们一南一北隔江而治，这中间信产部当然难辞其咎，但两大运营商也不该将错就错，偏安一方，电信拆分已经四年多了，中国的电信用户在资费和服务方面并没有得到多大的改善，与这种荒唐的竞争方式有直接的关系，在北方，如果你对网通不满，你唯一能做就是继续不满，并没有多少电信的网络资源供你选择，所以，如果你想对网通发火，最好先到楼道里看看那里有没有电信的接入盒，如果没有，赶紧收声吧。然而，如果你因此说网通的服务差，那也不对，事实上，网通的服务很到位，10060 基本随时可以接通，人工座席的声音也算甜美，一个服务请求一般会招来三到四个回访电话，这点和海尔颇有一拼，但海尔的皮毛好学，精髓难通，海尔在服务的时候基本不回避问题，他们的客服对任何问题都能说到点上，网通的客服却总是先将自己撇清。&lt;br /&gt;　　&lt;br /&gt;　　&lt;br /&gt;　　4. 唯利是图与泼脏水倒掉孩子&lt;br /&gt;　　&lt;br /&gt;　　电信和医疗教育一样，是国家垄断的公众资源，要求运营者拥有一定的社会责任，但网通和电信显然都掉进了钱眼，只要肯付钱，你做什么他们并不关心，这就是中国成为垃圾邮件天堂的原因。在世界几大反垃圾邮件组织（如 SORBS 和 ABUSE）的黑名单中，中国有成段成段的 IP 被列入，广州电信 IDC 的 IP 段在 2004 年曾被全球的邮件服务器抵制，我曾经多次给 SORBS 发邮件解释这个问题，也曾向香港的一家 ISP 交涉，在那段时间，我的用户几乎没有办法向国外发信，他们只要一听到广州电信 IDC 就连声说 NO，如今，广州电信又走入另一个极端，他们决心整治垃圾邮件服务器，整治的办法就是让非法与合法的邮件服务器一起玉石俱焚，大家知道，出于反垃圾邮件考虑，很多邮件服务器使用了反向 DNS 查询机制，以确认邮件的来源是否合法（因为 SMTP 协议是没有办法知道邮件域名和地址是否是伪造的），这就要求为你的邮件服务器的 IP 地址添加一条 PTR 记录，广州电信已经不受理这种业务了，即使受理，费用也高达 200元每月，厚黑到无以复加的程度。&lt;br /&gt;　　&lt;br /&gt;　　&lt;br /&gt;　　5. 事上而媚者必临下而骄&lt;br /&gt;　　&lt;br /&gt;　　企业和用户站在一起天经地义，因为你收了用户的钱，政府出于利己因素对国际互联网进行限制也无可厚非，但政府不是行业专家，作为电信运营商，你完全可以凭借自己的专业知识影响政府的决策，比如对国外某些站点的屏蔽，据我所知，很多被屏蔽的资源其实并没有什么问题，比如 wiki 和 dyndns，它们是纯粹的技术和文化性站点，即使有点杂音，也瑕不掩瑜，政府要实行屏蔽，首先要电信运营商合作，完全可以想象，网通和电信高级官僚是以怎样的媚骨迎合政府官员，没准还额外饶上几个。当你发现某些国外的站点无法访问的时候，你唯一能找的就是运营商，但他们根本提供不了任何帮助，他们首先要让他们的上级舒服，至于用户，先站一边吧。 wiki 无法访问已经超过半年了，顺便纪念一下。&lt;br /&gt;　　&lt;br /&gt;　　&lt;br /&gt;　　6. 先斩后奏或者不奏&lt;br /&gt;　　&lt;br /&gt;　　中国电信是否限制路由器共享上网，中国网通是否封杀 BT ，你的 10M 小区宽带实际带宽是多少，这都是些你明白，我明白，大家明白却没有人承认的问题。2004年，南方盛传中国电信使用了一种叫做网络尖兵的设备对路由器共享上网进行限制，当时我的一家企业用户已经被这个问题折磨的死去活来，我出面和当地的电信进行交涉，出人意料的是，他们对此一口否认，却回答不了为什么单机上网一切正常，一启用路由器就掉线的问题，为此，我亲自测试了市场上至少五款路由器，最后，一个客服实在看不下去，偷偷跟我说了一句同样很经典的话，“你说的问题，我也不说有，也不说没有，反正我们保证你的 ADSL 在一台电脑上是可用的，其他的你自己琢磨好了”。&lt;br /&gt;　　&lt;br /&gt;　　2005年底开始，网络有传北方网通开始封杀 BT，也是从那个时候开始，我的 Emule 开始出问题，只要一开 Emule，整个局域网就开始断断续续地离线，网通对此的解释仍旧是病毒，或者 Emule 对带宽的吞噬，但即使你将 Emule 的上下行连接速度限制到 10K 以下仍不起作用，经过研究，我发现只要将并发连接数减小到一定程度，马上会有改观，这印证了很多人对网通使用连接数封杀 BT 的猜测，而真正的内幕，也许无人得知，10060 对这件事的标准答复是非常安全的“尚未接到通知”。&lt;br /&gt;　　&lt;br /&gt;　　&lt;br /&gt;　　7. 永远的霸王&lt;br /&gt;　　&lt;br /&gt;　　消协对全国各行业霸王条款的调查显示，电信行业居首。电信行业的霸王条款多到数不清，网络中也有数不清的文章对这些霸王条款一条一条地进行揶揄，但无人能够撼动霸王的地位。几天前，我的家用 ADSL 准备续期，由于对 1M 的速率根本不满意，而中国互联网的瓶颈又根本不在这 1M 还是 2M，我便准备将 1M 的速率换成 512K，为了安全起见，我提出先试用 512K 一个月，如果有问题，再换回 1M，10060 马上提醒需要额外交 30 元手续费，我便举了很多例子，说明这 30 块实在没有道理，比如说吧，你去买茄子，说买一斤，然后又说买两斤，小贩会额外收你 30 块吗，不会；你去喝啤酒，说老板来两瓶，喝完了再加两瓶，人家会额外收你 30 块吗，不会；或者你去剃头，剃完了再刮刮脸，理发师会额外收你 30 块吗，也不会，那为什么你们要额外收这 30 块，网通的客服说，这是经物价局核定过的。一点题外话，内人就要生产了，上周陪她作 B 超，B 超费是 80 元，还要再交 10 元出报告，难道我出 80 元是让你们白看不成，在我们的国家，很多人信奉名正则言顺的道理，所以他们费尽心机为自己的不良行为找借口，因此我更欣赏强盗，他们要率真得多。 &lt;br /&gt;&lt;br /&gt;From 新京报</description>
  <comments>http://techonly.livejournal.com/12908.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>2</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://techonly.livejournal.com/12607.html</guid>
  <pubDate>Wed, 20 Sep 2006 01:52:52 GMT</pubDate>
  <title>Intel® PRO/Wireless 2100 Driver for Linux</title>
  <link>http://techonly.livejournal.com/12607.html</link>
  <description>&lt;a href=&quot;http://ipw2100.sourceforge.net/&quot;&gt;http://ipw2100.sourceforge.net/&lt;/a&gt;</description>
  <comments>http://techonly.livejournal.com/12607.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>2</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://techonly.livejournal.com/12492.html</guid>
  <pubDate>Tue, 19 Sep 2006 16:45:08 GMT</pubDate>
  <title>Just memorize the &quot;nine-planet&quot; time~</title>
  <link>http://techonly.livejournal.com/12492.html</link>
  <description>Mercury, Venus, Earth, Mars, Jupiter, Saturn, Uranus, Neptune, and &lt;b&gt;Pluto&lt;/b&gt;</description>
  <comments>http://techonly.livejournal.com/12492.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://techonly.livejournal.com/12042.html</guid>
  <pubDate>Tue, 19 Sep 2006 05:38:22 GMT</pubDate>
  <title>Load Average (LA)</title>
  <link>http://techonly.livejournal.com/12042.html</link>
  <description>&lt;a href=&quot;http://www.teamquest.com/resources/gunther/display/4/index.htm&quot;&gt;http://www.teamquest.com/resources/gunther/display/4/index.htm&lt;/a&gt;</description>
  <comments>http://techonly.livejournal.com/12042.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://techonly.livejournal.com/11881.html</guid>
  <pubDate>Mon, 28 Aug 2006 03:09:46 GMT</pubDate>
  <title>The Ten Commandments of Computer Ethics</title>
  <link>http://techonly.livejournal.com/11881.html</link>
  <description>1.Thou shalt not use a computer to harm other people. &lt;br /&gt;2.Thou shalt not interfere with other people&apos;s computer work. &lt;br /&gt;3.Thou shalt not snoop around in other people&apos;s computer files. &lt;br /&gt;4.Thou shalt not use a computer to steal. &lt;br /&gt;5.Thou shalt not use a computer to bear false witness. &lt;br /&gt;6.Thou shalt not copy or use proprietary software for which you have not paid. &lt;br /&gt;7.Thou shalt not use other people&apos;s computer resources without authorization or proper compensation. &lt;br /&gt;8.Thou shalt not appropriate other people&apos;s intellectual output. &lt;br /&gt;9.Thou shalt think about the social consequences of the program you are writing or the system you are designing. &lt;br /&gt;10.Thou shalt always use a computer in ways that insure consideration and respect for your fellow humans. &lt;br /&gt;&lt;br /&gt;Source: Computer Ethics Institute.</description>
  <comments>http://techonly.livejournal.com/11881.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://techonly.livejournal.com/11562.html</guid>
  <pubDate>Wed, 23 Aug 2006 14:29:51 GMT</pubDate>
  <title>Study Perl</title>
  <link>http://techonly.livejournal.com/11562.html</link>
  <description>Perl学习指南&lt;br /&gt;&lt;a href=&quot;http://www.perlchina.org/archive/archive.php?action=archive&amp;page=46&quot;&gt;http://www.perlchina.org/archive/archive.php?action=archive&amp;page=46&lt;/a&gt;</description>
  <comments>http://techonly.livejournal.com/11562.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://techonly.livejournal.com/11417.html</guid>
  <pubDate>Wed, 16 Aug 2006 07:05:28 GMT</pubDate>
  <title>IPMI</title>
  <link>http://techonly.livejournal.com/11417.html</link>
  <description>1. Install IPMI card on motherboard&lt;br /&gt;2. Add patch to system kernel. (redhat9 and later versions default support IPMI). You can check whether there is directory /lib/modules/2.*.*/kernel/drivers/char/ipmi/.&lt;br /&gt;3. Insert modules into system&lt;br /&gt;# insmod ipmi_msghandler&lt;br /&gt;# insmod ipmi_kcs_drv&lt;br /&gt;# insmod ipmi_devintf&lt;br /&gt;4. Make character device node, in order for ipmitool access ipmi system interface&lt;br /&gt;# cat /proc/devices | grep ipmidev&lt;br /&gt;254 ipmidev&lt;br /&gt;# mknod /dev/ipmi0 c 254 0&lt;br /&gt;5. Install ipmitool (&lt;a href=&quot;http://ipmitool.sourceforge.net/&quot;&gt;http://ipmitool.sourceforge.net/&lt;/a&gt;)&lt;br /&gt;6. Here come the issue of controlling other machines.&lt;br /&gt;# ipmitool -I lan -H host -U user -a channel info&lt;br /&gt;host: IP address&lt;br /&gt;user: root (This is set in BIOS, after press &quot;Ctrl-E&quot;)&lt;br /&gt;It&apos;s not a must to install IPMI card on the master host with ipmitool.&lt;br /&gt;&lt;br /&gt;Some example commands:&lt;br /&gt;# Ipmitool -I lan host root chassis power status&lt;br /&gt;# Ipmitool -vI lan host root chassis power soft</description>
  <comments>http://techonly.livejournal.com/11417.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
</channel>
</rss>
