hongmeig's WebLog

  • How to see windows using remote desktop with dual monitors

    Let us say i want to connect my laptop to my office machine, which uses dual monitors. I can see some of the windows icons showing up in the taskbar, but i cannot see the window. How can I click any button on that window?

    Here is the solution:

    Right click on the window you want on the taskbar, select move, hit any arrow button, move your mouse.

     

     

  • A possible solution to a common sql error

    If you happen to get the following sql error: 

     

    An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005 or above, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections..

     

    You are not alone. There are a lot of solutions out on the web, the best i can find is this:

     

    http://sequelserver.blogspot.com/2007/06/under-default-settings-sql-server-does.html

     

    However, the error i am getting is actually because i have installed the full version of SQL without the SQL Express. However, my sql command was actually calling

     

    sqlcmd -S localhost \sqlexpress -E -b –d databaseName -i sqlScriptPath

     

    instead you need to call

     

    sqlcmd -S localhost  -E -b –d databaseName -i sqlScriptPath

  • How to make a 24'' monitor look better

    1920 X 1200 is the resolution you wanted for the 24" monitor. The old 1600 X 1200 would make everything looks flattened. So what if my highest resolution is 1600 X 1200? The solution is that you need to update your new driver. Here is how you can do it on Vista.

     Right click on mouse, click Personalize->Display Settings ->Advanced Settings ... -> Monitor -> Properties -> Driver -> Update Driver ..., automatic updating should usually work.

     Then you should find the 1920 X 1200 as the highest resolution, select that and you should see everything clearly.

  • WCF error: Cannot resolve KeyInfo for unwrapping key: KeyInfo 'SecurityKeyIdentifier

    If you are getting an error like : Cannot resolve KeyInfo for unwrapping key: KeyInfo 'SecurityKeyIdentifier and your have checked that your certificate is in the right store and right place.

    So this might be the reason. check the binding you have and make sure the negotiateServiceCredential has the same value. By default, it is true.

    Reason? The server will use this flag to try to build the primary token resolver which is being used to resolve those key info clause. If that flag is ture, then the server will load the server certificate into the primary token resolver, so it will fail to resolve the key info if client sends one.

    So where is that flag? Here is an example where this could be located:

    <wsHttpBinding>

    <binding ...>

    <security mode="Message">

    <message clientCredentialType="Windows" negotiateServiceCredential="true"

    algorithmSuite="Default" establishSecurityContext="true" />

    </security>

    </binding>

    </wsHttpBinding>

     Hope this helps!

  • Going to Tech Ed China 2007

    I am going to attend Tech Ed China 2007 again. I am very excited about it.

    http://www.microsoft.com/china/technet/teched/speakers/default.mspx

     

  • How to pass custom object between WCF client app and custom issued security token provider

    There are two options:

    1. OperationContext.Current.

    Pros: This is pretty straightforward and relatively hard to discover. 

    Cons: This is a thread local storage, and you are invoking a async call, it does not work well.

    2. ChannelParameterCollection

    This is very sneaky. You will need to add the object to channel first in your client app code,

                                    // add the token to the channel parameter collection

                                   ChannelParameterCollection parm = (ChannelParameterCollection)( (IChannel)client ).GetProperty<ChannelParameterCollection>();

                    parm.Add( myState);

    Then you can retrieve it from the requirement, and set it on the custom token provider

    public override SecurityTokenProvider CreateSecurityTokenProvider( SecurityTokenRequirement tokenRequirement )

            {

                // retrieve the ChannelParameterCollection from the token requirements

                                    ChannelParameterCollection collection = null;

                    if ( !tokenRequirement.TryGetProperty<ChannelParameterCollection>( ServiceModelSecurityTokenRequirement.ChannelParametersCollectionProperty, out collection ) )

                    {

                        Console.WriteLine( "could not found ChannelParameterCollection" );

                    }

     

                      // now add the collection to your issuedsecuritytokenprovider

                CustomIssuedSecurityTokenProvider federationTokenProvider = new CustomIssuedSecurityTokenProvider(collection);

     

    }

    The last step is to simply retrieve it from the BeginGetTokenCore() method

     public class CustomIssuedSecurityTokenProvider : IssuedSecurityTokenProvider

        {

            ChannelParameterCollection _collection;

     

            /// <summary>

            /// Constructor

            /// </summary>

            public CustomIssuedSecurityTokenProvider(ChannelParameterCollection collection)

                : base()

            {

                _collection = collection;

            }

     

            ChannelParameterCollection Collection

            {

                get

                {

                    return _collection;

                }

            }

            protected override IAsyncResult BeginGetTokenCore( TimeSpan timeout, AsyncCallback callback, object state )

            {

                foreach ( object o in _collection )

                {

                    if ( o is someType)

                    {

                        // turn it into your type

                    }

                }

               

               

            }

    }

    Hope it helps

  • Generating user instances in SQL Server is disabled. Use sp_configure 'user instances enabled' to generate user instances

    If you are getting the following error:

    “Generating user instances in SQL Server is disabled. Use sp_configure 'user instances enabled' to generate user instances” What should I do?

     

    Answer: To fix this, please Open the SQL Server Management Studio Express. This is the downloadable program in the same site where you downloaded the SQL Server 2005 express used to manage SQL Server 2005 Express.

    In the query editor type this text: exec sp_configure 'user instances enabled', 1.

    Then type: Reconfigure.

    Then restart the SQL Server database.

  • How to make IIS hosted WCF service work with Card Space using localhost

    First let me explain why it does not work.

    There are three string comparisons done by card space. The information card has Issuer, IssuerEndpointAddress, and IssuerMexAddress.

    When you hit a web site which requires an information card, in other words, it contains a object tag which has specified the Issuer and Mex address.

    Comparison 1: CardSpace UI would do a string comparison between the Issuer specified in the object tag and all the cards it has, and light up only those matches.

    Comparison 2: Then when you select a hightlighted card, it uses the IssuerMexAddress inside the card to retrieve wsdl from the issuer. When the wsdl returns, it then compares the address inside the wsdl and the IssuerEndpointAddress inside the card. It fails if it does not match.

    If everything goes well, it will go to the Issuer to get the token.

    So why localhost does not work by default?

    IIS hosted WCF service's Issuer Endpoint Address would be fully qualifed domain name, something like mymachinename.mydomain.com. Literally it would not match localhost. So the comparison 1 would fail, where the card would specify the fully qualifed domain name, so the card would not even light up. Even if you managed to make the card issuer name use the localhost, and select the card, the mex retrieval process is going to fail because you will try to send a mex request to the https://mymachine.mydomain.com/..., but your ssl cert is actuall localhost. This will fail because https will compare validate the ssl cert.

    Two ways to fix it.  

    First option is to modify the IIS setting so that the WCF service will indeed host over the localhost. Two simple command line would do.

    cscript //nologo %systemdrive%\inetpub\adminscripts\adsutil.vbs set W3SVC/1/ServerBindings :80:localhost

    cscript //nologo %systemdrive%\inetpub\adminscripts\adsutil.vbs set W3SVC/1/SecureBindings :443:localhost

    This will make the IIS hosted WCF service really use localhost.

    Second option is to modify the manged card so that its Issuer Name is http://localhost/..., its token service endpoint address is http://mymachine.mydomain.com/... and my token service mex endpoint address is https://localhost/.../mex

     

  • How to use findstr with regular expression

    By default findstr does the comparison with regular expression. However, what surprised me is that the following command does not work.

     findstr "abc|def" test.txt

    when test.txt has only abc in it.

    According to the online tutorial such as http://www.regular-expressions.info/reference.html, abc|efg should match abc. Why?

    The reason is pretty simple, findstr does not support the full range of the regular expression. It does not support ?, {n}.

    Some basic things works: 

    findstr "abc.*" test.txt

    findstr "[0-9a-f].*" test.txt

     

     

     

  • How to change your web site from https://localhost to https://mydomain.com

    There are three steps you need to take to make it work.

     1. Modify your hosts file under \Windows\System32\drivers\etc\hosts and add the following entry:

    127.0.0.1    mydomain.com

    2. Turn off your proxy dection from the IE,

     Go to Tools->Internet Options->Connection->LAN Settings, uncheck everything

    3. Modify your binding in the IIS manager to use mydomain.com instead of localhost as host header.

    http://blogs.msdn.com/wenlong/archive/2007/08/02/how-to-change-hostname-in-wsdl-of-an-iis-hosted-service.aspx

     

    BTW, you need to remove the quote here. 

     

    So instead of

     

    cscript //nologo %systemdrive%\inetpub\adminscripts\adsutil.vbs set W3SVC/1/SecureBindings “:443:www.fancydomain.com”

     

    you shoud do 

     

    cscript //nologo %systemdrive%\inetpub\adminscripts\adsutil.vbs set W3SVC/1/SecureBindings :443:www.fancydomain.com

     

     

     

    Hope this helps.

  • How do I turn on windows authentication in IIS 7

    In IIS 6, you can start the IIS manager by typing the inetmgr at the Start->Run windows, and click on the web site, Right click on the web site, go to the directory security, you will have windows authentication check box to click.

    In IIS 7, it is not the case. Windows Authentication is not installed by default. You need to explicitly install it by going to control panel/turn windows feature on/off. Go to the IIS\world Wide Web Services\Security, and check the windows authentication box to install it.

     

  • CardSpace: Why can't i select my personal card

    You need to make sure that your personal card contains the required claim types you specified in your client binding. To fix this, try set the required claim types to one of the claims that your personal card has.

    WSFederationHttpBinding binding = new WSFederationHttpBinding( WSFederationHttpSecurityMode.Message );

    // the required claim sections

    binding.Security.Message.ClaimTypeRequirements.Add( new ClaimTypeRequirement( ClaimTypes.GivenName ) );

     

  • Card Space exception: incoming policy failed validation

    One possibility is that your binding does not contains required claim types. In your client binding, make sure you have at least one required claims:

    WSFederationHttpBinding binding = new WSFederationHttpBinding( WSFederationHttpSecurityMode.Message );

     

    // the required claim sections

    binding.Security.Message.ClaimTypeRequirements.Add( new ClaimTypeRequirement( ClaimTypes.Name ) );

     

    // the optional claim sections

    binding.Security.Message.ClaimTypeRequirements.Add( new ClaimTypeRequirement( ClaimTypes.Gender, true ) );

    Hope this helps 

     

     

  • Make the WCF service take the personal card

    The common error that users will run into for the personal card scenario is that the WCF service cannot verify the signing credentials of the saml token. This is because the personal card will trigger the card space runtime to issue a saml token signed by rsa key. And you need to turn on one boolean to make it work.

    sh.Credentials.IssuedTokenAuthentication.AllowUntrustedRsaIssuers = true;

     

  • WCF exception: The remote certificate is invalid according to the validation procedure

    If you are using Https, this might fix it.

                ServicePointManager.ServerCertificateValidationCallback = RemoteCertificateValidationCallback;

     

     

       public static bool RemoteCertificateValidationCallback(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)

            {

                // do some validation here...

            }

     

    Please refer to http://blogs.msdn.com/suwatch/archive/2007/04/06/x509-and-wcxf-security.aspx for a complete picture.

More Posts Next page »

© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Microsoft
Page view tracker