Newbie to security -- I'm stuck.

From: Rob (Rob_at_discussions.microsoft.com)
Date: 10/15/04

  • Next message: Dave: "How do I distribute an msi file using group policy?"
    Date: Fri, 15 Oct 2004 13:55:17 -0700
    
    

    This should be simple, but I can't seem to figure this out. I have a Windows
    Service application and a GUI to interface to it. The service logs data to a
    SQL Server database. I have the Login and Password for the database in the
    Registry and I wish to encrypt it. The service retrieves the Login and
    Password from the registry and the GUI sets the Login and Password to the
    registry.

    The GUI can set the encrypted Login and Password to the registry and can
    read the encrypted Login and Password from the registry and display them.
    There is no problem here. But the service using the same Key Container Name
    as the GUI cannot decrypt the Login or Password and returns a "Bad Data"
    exception.

    Can anyone explain what I have done wrong? Any help is appreciated! Here
    is a snippet of my code:

    To read from the Registry -

    Dim cp As New CspParameters
    cp.KeyContainerName = _KEYCONTAINERNAME
    Dim rsa As New RSACryptoServiceProvider(cp)

    Login = Convert.ToBase64String(rsa.Decrypt(CType(GetRegistryValue("Login"),
    Byte()), False))
    Password =
    Convert.ToBase64String(rsa.Decrypt(CType(GetRegistryValue("Password"),
    Byte()), False))

    To write to the Registry -

    Dim cp As New CspParameters
    cp.KeyContainerName = _KEYCONTAINERNAME
    Dim rsa As New RSACryptoServiceProvider(cp)

    SetRegistryValue("Login",
    rsa.Encrypt(Convert.FromBase64String(txtLogin.Text), False))
    SetRegistryValue("Password",
    rsa.Encrypt(Convert.FromBase64String(txtPassword.Text), False))


  • Next message: Dave: "How do I distribute an msi file using group policy?"

    Relevant Pages

    • Re: Local logon for terminal server without specifying machine name?
      ... MCSE, CCEA, Microsoft MVP - Terminal Server ... I made the changes as said below to the registry. ... was used in the pull down list on the windows login screen. ... I want to set up a local account on a terminal server machine ...
      (microsoft.public.windows.terminal_services)
    • Re: Login Loop
      ... The userinit value may have been corrupted by ... system registry, sometimes appending it, sometimes replacing it. ... This is particularly useful if you have an OEM installation ... > to the login screen asking me to press ctrl-alt-del to login. ...
      (microsoft.public.windowsxp.basics)
    • Re: XP sends me back to the login screed after I login
      ... and then XP sends me back to the login screen. ... The problem may be an incorrect system drive letter. ... make sure you disconnect the machine from the registry. ... How to restore the system/boot drive letter in Windows ...
      (microsoft.public.windowsxp.help_and_support)
    • Re: VB6 Login Form to SQL Server
      ... Thank you -- I'll add to last login and last database to registry and ... pre-fill textbox each time Login form is displayed. ... > Attempting to open a connection without knowing with certainty that the ... It may seem adequate responsive once the server is ...
      (microsoft.public.vb.general.discussion)
    • Re: VB6 Login Form to SQL Server
      ... Thank you -- I'll add to last login and last database to registry and ... pre-fill textbox each time Login form is displayed. ... > Attempting to open a connection without knowing with certainty that the ... It may seem adequate responsive once the server is ...
      (microsoft.public.vb.database)