farvelocity

博客园 首页 新随笔 联系 订阅 管理

由于判断局域网IP地址是否合法用户,同时访问自己设定的网络服务(根据网络环境不同,可能部署的IP不同),使用下面方式轮询了局域网IP,通过页面进行显示,基本上能判定intranet的网络IP地址
  
      DirectoryEntry root = new DirectoryEntry("WinNT:");
        DirectoryEntries domains = root.Children;      
        domains.SchemaFilter.Add("domain");
        foreach (DirectoryEntry domain in domains)
        {
            Response.Write("domain name: " + domain.Name + "<br>");
            DirectoryEntries computers = domain.Children;
            computers.SchemaFilter.Add("computer");
            foreach (DirectoryEntry computer in computers)
            {
                Response.Write("computers name: " + computer.Name + "<br>");
                string strcomputername = computer.Name;
                try
                {
                    IPHostEntry iphe = Dns.GetHostByName(strcomputername);
                    foreach (IPAddress ip in iphe.AddressList)
                    {
                        Response.Write("computers ip: " + ip + "<br>");
                    }

                }
                catch (Exception e)
                {
                   
                    //throw;
                }
                DirectoryEntries users = computer.Children;
            }
        }

posted on 2008-05-08 14:47  greatwall  阅读(578)  评论(0编辑  收藏  举报