2017-07-21 4 views
-1

Ich arbeite gerade an einem Programm, das die Korrektur von Computereinstellungen übernimmt, die meine Abteilung regelmäßig repariert. Eine solche Einstellung ist eine 802.1x-Profilkonfiguration für zwei verschiedene Netzwerkadapter. Das Programm muss die Authentifizierung in den Einstellungen des lokalen Netzwerks und des Ethernet-Adapters auf "Benutzerauthentifizierung" ändern.Wie kann ich VB.NET dazu bringen, eine XML-Datei aus vorgefertigtem XML-Code auszugeben?

Um dies zur Zeit zu bewältigen, haben wir ein Programm namens BigFix, mit dem wir Pakete erstellen und diese über das Netzwerk bereitstellen können, um solche Änderungen vorzunehmen. Unser aktueller Fix teilt BigFix mit dem BigFix-Aktionsskript mit, dass eine XML-Datei in einem Verzeichnis erstellt und dann mit netsh-Befehlen ausgeführt wird, um die Einstellungen zu importieren.

Mein Problem ist, dass ich nicht für das Leben von mir herausfinden kann, wie man das vorgefertigte XML-Skript nimmt und VB.NET erhält, es in eine .xml-Datei auszugeben. Ein noch größeres Problem hier ist, dass ich weiß, VB.NET hat Tools, um dies zu tun, aber ich weiß nicht, wie in XML AT ALL zu schreiben.

Könnte mich jemand auf eine Lösung hinweisen/mir zeigen, wie ich das mache, wonach ich suchen möchte? Hier ist das folgende XML-Dokument:

<?xml version="1.0" encoding="UTF-8"?> 
<LANProfile xmlns="http://www.microsoft.com/networking/LAN/profile/v1"> 
    <MSM> 
    <security> 
     <OneXEnforced>false</OneXEnforced> 
     <OneXEnabled>true</OneXEnabled> 
     <OneX xmlns="http://www.microsoft.com/networking/OneX/v1"> 
     <cacheUserData>true</cacheUserData> 
     <authMode>user</authMode> 
     <EAPConfig> 
      <EapHostConfig xmlns="http://www.microsoft.com/provisioning/EapHostConfig"> 
      <EapMethod> 
       <Type xmlns="http://www.microsoft.com/provisioning/EapCommon">25</Type> 
       <VendorId xmlns="http://www.microsoft.com/provisioning/EapCommon">0</VendorId> 
       <VendorType xmlns="http://www.microsoft.com/provisioning/EapCommon">0</VendorType> 
       <AuthorId xmlns="http://www.microsoft.com/provisioning/EapCommon">0</AuthorId> 
      </EapMethod> 
      <Config> 
       <Eap xmlns="http://www.microsoft.com/provisioning/BaseEapConnectionPropertiesV1"> 
       <Type>25</Type> 
       <EapType xmlns="http://www.microsoft.com/provisioning/MsPeapConnectionPropertiesV1"> 
        <ServerValidation> 
        <DisableUserPromptForServerValidation>false</DisableUserPromptForServerValidation> 
        <ServerNames /> 
        </ServerValidation> 
        <FastReconnect>true</FastReconnect> 
        <InnerEapOptional>false</InnerEapOptional> 
        <Eap xmlns="http://www.microsoft.com/provisioning/BaseEapConnectionPropertiesV1"> 
        <Type>26</Type> 
        <EapType xmlns="http://www.microsoft.com/provisioning/MsChapV2ConnectionPropertiesV1"> 
         <UseWinLogonCredentials>true</UseWinLogonCredentials> 
        </EapType> 
        </Eap> 
        <EnableQuarantineChecks>false</EnableQuarantineChecks> 
        <RequireCryptoBinding>false</RequireCryptoBinding> 
        <PeapExtensions> 
        <PerformServerValidation xmlns="http://www.microsoft.com/provisioning/MsPeapConnectionPropertiesV2">true</PerformServerValidation> 
        <AcceptServerName xmlns="http://www.microsoft.com/provisioning/MsPeapConnectionPropertiesV2">false</AcceptServerName> 
        </PeapExtensions> 
       </EapType> 
       </Eap> 
      </Config> 
      </EapHostConfig> 
     </EAPConfig> 
     </OneX> 
    </security> 
    </MSM> 
</LANProfile> 
+0

Was ist dieses "vorgefertigte XML-Skript"? –

Antwort

0

Hilft der folgende Code?

Imports System.Xml 
Imports System.Xml.Linq 
Imports System.IO 

Module Module1 
    Const INPUT_FILENAME As String = "c:\temp\test.txt" 
    Const OUTPUT_FILENAME As String = "c:\temp\test.xml" 

    Sub Main() 
     Dim xml As String = File.ReadAllText(INPUT_FILENAME) 

     Dim doc As XDocument = XDocument.Parse(xml) 

     doc.Save(OUTPUT_FILENAME) 

    End Sub 

End Module 
Verwandte Themen