Write Namevalue pair into Config file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Shaun Ram

    Write Namevalue pair into Config file


    Hi I have this constraint. A help would be greatly apprecitated.
    I have this Config file.

    <?xml version="1.0" encoding="utf-8" ?>
    <configuratio n>
    <configSections >
    <sectionGroup name="ITASCA">
    <section name="Connectio nString"
    type="System.Na mevaluesectionH andler,System" />
    </sectionGroup>
    </configSections>

    <ITASCA>
    <ConnectionStri ng>
    <add key="projcode1" value="database "/>
    <add key="projcode2" value="database 2"/>
    </ConnectionStrin g>
    </ITASCA>


    I use VB.NET to read this section
    I want to use DPAPI with Machine store. For this I have to read the
    connection string from config file as name value pair, Then encrypt the
    connection string & want to replace back the encrypted string into the
    same section of config file.
    I have a issue in writing into the same section. Couple somebody please
    help me with writing as name value pair, as a attribute into the
    section.
    I used configuration management application block from microsoft to
    write. But then I was unable to write as an attribute to a element in a
    node.

    A help would be greatly apprecitated.
    Thanking you
    Shaun



    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
  • Christoph Schittko [MVP]

    #2
    Re: Write Namevalue pair into Config file

    What exactly is your issue? How are you opening the config file? Are you
    sure it's read/write?
    What exception are you seeing?


    --
    HTH
    Christoph Schittko [MVP, XmlInsider]
    Software Architect, .NET Mentor


    "Shaun Ram" <tronicsolution @yahoo.com> wrote in message
    news:epMB0AV3DH A.1504@TK2MSFTN GP12.phx.gbl...[color=blue]
    >
    > Hi I have this constraint. A help would be greatly apprecitated.
    > I have this Config file.
    >
    > <?xml version="1.0" encoding="utf-8" ?>
    > <configuratio n>
    > <configSections >
    > <sectionGroup name="ITASCA">
    > <section name="Connectio nString"
    > type="System.Na mevaluesectionH andler,System" />
    > </sectionGroup>
    > </configSections>
    >
    > <ITASCA>
    > <ConnectionStri ng>
    > <add key="projcode1" value="database "/>
    > <add key="projcode2" value="database 2"/>
    > </ConnectionStrin g>
    > </ITASCA>
    >
    >
    > I use VB.NET to read this section
    > I want to use DPAPI with Machine store. For this I have to read the
    > connection string from config file as name value pair, Then encrypt the
    > connection string & want to replace back the encrypted string into the
    > same section of config file.
    > I have a issue in writing into the same section. Couple somebody please
    > help me with writing as name value pair, as a attribute into the
    > section.
    > I used configuration management application block from microsoft to
    > write. But then I was unable to write as an attribute to a element in a
    > node.
    >
    > A help would be greatly apprecitated.
    > Thanking you
    > Shaun
    >
    >
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it![/color]


    Comment

    • Shaun Ram

      #3
      Re: Write Namevalue pair into Config file

      Thanks for responding.
      The requirement is:
      I have the connection string in web.config file. This needs to be
      encrypted using DPAPI.
      But I can't use Registry or user store(Can't use Serviced components to
      load profile)
      So I'm trying to implement DPAPI with Machine Store.

      But then on the deployment server, if the connection string is encrypted
      on developer's machine I will not be able to decrypt it on server end
      for application,
      So I though if I could Encrypt & write the connection string at runtime
      to the config file at server end, I could also decrypt at the server
      end. This way the developers could use the encrypted string from the
      server. (This issue poses problem during production & deployment)

      Another question, with DPAPI Machine store can I Remotely log-in into
      the server & decrypt the connection string?
      If this works then I will not have to write into config file.

      Do you have any sugestions for this requirement
      Thanking you in advance
      Shaun

      *** Sent via Developersdex http://www.developersdex.com ***
      Don't just participate in USENET...get rewarded for it!

      Comment

      Working...