locked
How to use WEBCREDENTIALS in Dataprotection Provider? RRS feed

  • Question

  • Can anyone show me how to use the "WEBCREDENTIALS=MyPasswordName,myweb.com" option for the DataProtectionProvider?  With the following code an exception is thrown on creation of the DataProtectionProvider object (Encryption failed. (Exception from HRESULT: 0x80090034)).

    public async void WriteMyFile(string theString)
            {
                String strDescriptor = "WEBCREDENTIALS=someone@hotmail.com,login.live.com";
                BinaryStringEncoding encoding = BinaryStringEncoding.Utf8;
    
                // Protect a message to the local user.
                IBuffer buffProtected = await this.myProtectAsync(theString, strDescriptor, encoding);
                StorageFile file = theFile; 
                try
                {
                        await FileIO.WriteBufferAsync(file, buffProtected );
      
                }
                catch (FileNotFoundException)
                {
                    rootPage.NotifyUserFileNotExist();
                }
    
                return;
            }        
    
    
    public async Task<IBuffer> myProtectAsync(
                       String strMsg,
                       String strDescriptor,
                       BinaryStringEncoding encoding)
            {
                // Create a DataProtectionProvider object for the specified descriptor.
                DataProtectionProvider Provider = new DataProtectionProvider(strDescriptor);
    
                // Encode the plaintext input message to a buffer.
                encoding = BinaryStringEncoding.Utf8;
                IBuffer buffMsg = CryptographicBuffer.ConvertStringToBinary(strMsg, encoding);
    
                // Encrypt the message.
                IBuffer buffProtected = await Provider.ProtectAsync(buffMsg);
    
                return buffProtected;
            }
    
    

    Saturday, December 14, 2013 3:49 AM

All replies

  • Saturday, December 14, 2013 5:30 AM
  • Yes, and neither explain how to use "WEBCREDENTIALS".  Both use the example of "LOCAL=user" to construct the DataProtectionProvider. 
    Saturday, December 14, 2013 8:13 AM
  • Yes, and neither explain how to use "WEBCREDENTIALS".  Both use the example of "LOCAL=user" to construct the DataProtectionProvider. 
     Same exception occurs when SID is used for strDescriptor.

    Nikhil Sharma10

    Wednesday, June 4, 2014 10:51 AM