Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 正在读取LiveDeviceID.xml以获取密码_C#_Xml_Dynamics Crm - Fatal编程技术网

C# 正在读取LiveDeviceID.xml以获取密码

C# 正在读取LiveDeviceID.xml以获取密码,c#,xml,dynamics-crm,C#,Xml,Dynamics Crm,我正在尝试联机连接到CRM Dynamics,如果我从控制台运行以下命令以获取用户名和密码,我就可以到达那里 deviceregistration.exe /operation:show 显然,如果我能以编程方式读取包含信息的XML,那会更好。然而,文件的内容被可怕地加密了,如下所示 <Data version="1"> <User username="1kz9u5e4t4br4nah8sm61coc" type="Logical"> <Pwd>

我正在尝试联机连接到CRM Dynamics,如果我从控制台运行以下命令以获取用户名和密码,我就可以到达那里

deviceregistration.exe /operation:show
显然,如果我能以编程方式读取包含信息的XML,那会更好。然而,文件的内容被可怕地加密了,如下所示

<Data version="1">
  <User username="1kz9u5e4t4br4nah8sm61coc" type="Logical">
    <Pwd>
      AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAASLr2v6+hUU2goUw2ivLu9AAAAAACAAAAAAA 
      QZgAAAAEAACAAAABvPcbpZtXzDjyRoQAm19c71KA3J6TpyU0rieu4WY/1OgAAAAAOgA
      AAAAIAACAAAAAT5Aunf6PBWDRp7UPKYrcP33tniAfAHf1MzEjcUAvVKSAAAAArJkRAv
      Ml+cgNy8fUscH//u41scGezSw+OOvOkpn86r0AAAADLmCwYMLVw+Qo5hPwxnlawMW7s
      0fvMJJkM1UiyfBQ49nJOF7v0pa32DtFFluDsjGv4Yddj7j+FtNiYNxmvzc0l
    </Pwd>
  </User>
</Data>

如何使用C获取真实数据?请注意,我知道如何访问该文件、读取其内容和处理XML结构以获取两个感兴趣的字符串。问题在于,它正从加密版本变为普通版本。

CRM SDK包含文件SDK\samplecode\cs\helpercode\deviceidmanager.cs。如果要联机连接Dynamics CRM,此文件将非常有用

    ClientCredentials credentials = new ClientCredentials();
    credentials.UserName.UserName = userName;
    credentials.UserName.UserName = userName;
    credentials.UserName.Password = password;

    IServiceManagement<IOrganizationService> orgServiceManagement = ServiceConfigurationFactory.CreateManagement<IOrganizationService>(new Uri(organizationUrl));

    AuthenticationCredentials authCredentials = new AuthenticationCredentials();
    authCredentials.ClientCredentials = credentials;
    authCredentials.SupportingCredentials = new AuthenticationCredentials();
    authCredentials.SupportingCredentials.ClientCredentials = Microsoft.Crm.Services.Utility.DeviceIdManager.LoadOrRegisterDevice();
    AuthenticationCredentials tokenCredentials = orgServiceManagement.Authenticate(authCredentials);
    var organizationTokenResponse = tokenCredentials.SecurityTokenResponse;

    OrganizationServiceProxy _serviceProxy;
    IOrganizationService _service;
    using (_serviceProxy = new OrganizationServiceProxy(orgServiceManagement, organizationTokenResponse))
    {
        _service = (IOrganizationService)_serviceProxy;

        WhoAmIResponse response = (WhoAmIResponse)_service.Execute(new WhoAmIRequest());
        Console.WriteLine(response.UserId.ToString());
    }