当我的系统未连接到网络时,我无法获取自己的系统目录详细信息 [英] I can't Fetch my own system directory details when my system is not connected to network

查看:96
本文介绍了当我的系统未连接到网络时,我无法获取自己的系统目录详细信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述







我使用.NET Framework 4.0,因为我创建了一个Windows应用程序来获取Active目录详细信息

i使用appconfig文件来给出机器的配置

当我尝试从Active目录中获取详细信息时,它会在连接到网络时提供用户列表但拔出时我的系统从网络它没有工作它提出目录Entry.Guid文件未找到异常但在网络连接它获得成功

请帮我解决这个问题



我的appconfig文件

Hi,


I am using .NET Framework 4.0 in that i have created one windows application to get the Active directory details
i have used appconfig file to give the configuration of machine
when i try to fetch the details from Active directory it gives the user list when it was connected to network but when unplug my system from network it's not working it raise the Directory Entry.Guid File not found exception but in network connection it get success
please help me to solve this issue

my appconfig file

<configSections>
      <sectionGroup name="Servers" type="System.Configuration.ConfigurationSectionGroup" >
        <section name="server1" type="System.Configuration.NameValueSectionHandler" />
      </sectionGroup>
    </configSections>
  <Servers>
   
    <server1>
      <add key="connectionstring" value="Data Source=datasource;Initial Catalog=database;User ID=xx;Password=password"/>
      <add key="entrypath" value="WinNT://domain/systemname"/>
      <add key="Username" value="domain\username"/>
      <add key="password" value="password"/>
    </server1>







foreach (ConfigurationSection config_section in section.Sections)
                        {
                            try
                            {
                                var servers = ConfigurationManager.GetSection(config_section.SectionInformation.SectionName) as NameValueCollection;

                                connection_string = servers["connectionstring"].ToString();
                                string Entrypath = servers["entrypath"].ToString();
                                string username = servers["Username"].ToString();
                                string password = servers["password"].ToString();
                                password = oVWSec.DecryptData(password);
                                DirectoryEntry entryPC = new System.DirectoryServices.DirectoryEntry(Entrypath, username, password);
                                
                                try
                                {
                                    debug_string.WriteLine("Connect to Server: " + Entrypath);
                                    WriteLog("Connect to Server: " + Entrypath);
                                    foreach (System.DirectoryServices.DirectoryEntry child in entryPC.Children)
                                    {
                                         //code to manipulate child node
}
}





它会在entryPC.Children中引发错误

在以下行中

foreach(entryPC.Children中的System.DirectoryServices.DirectoryEntry子句)



帮我解决这个问题



it raise the error in entryPC.Children
in the following line
foreach (System.DirectoryServices.DirectoryEntry child in entryPC.Children)

help me to solve this

推荐答案

Windows中的网络层需要连接的网络才能加载和激活。



在这种情况下,最好的选择是添加Microsoft环回网络适配器和例如,使用IP地址192.168.10.1配置它,一切都会正常工作。
The networking layer in Windows requires a connected network to even load and be active.

Your best option under this condition is to add a "Microsoft Loopback Network adapter" and configure it with an IP address of say 192.168.10.1 for example and everything will work.


这篇关于当我的系统未连接到网络时,我无法获取自己的系统目录详细信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆