国产宅男网站在线|亚洲A级性爱免费视频|亚洲中精品级在线|午夜福利AA毛

  • <dd id="gf5jf"><th id="gf5jf"></th></dd>

    <cite id="gf5jf"><label id="gf5jf"></label></cite>
  • <div id="gf5jf"><listing id="gf5jf"></listing></div>
    學(xué)習(xí)啦 > 學(xué)習(xí)電腦 > 網(wǎng)絡(luò)知識(shí) > 網(wǎng)絡(luò)基礎(chǔ)知識(shí) >

    asp.net實(shí)現(xiàn)訪問局域網(wǎng)共享目錄下文件教程

    時(shí)間: 加城1195 分享

      局域網(wǎng)通常是分布在一個(gè)有限地理范圍內(nèi)的網(wǎng)絡(luò)系統(tǒng),一般所涉及的地理范圍只有幾公里。局域網(wǎng)專用性非常強(qiáng),具有比較穩(wěn)定和規(guī)范的拓?fù)浣Y(jié)構(gòu)。這篇文章主要介紹了asp.net實(shí)現(xiàn)訪問局域網(wǎng)共享目錄下文件的解決方法,需要的朋友可以參考下

      方法步驟

      using System;

      using System.Collections;

      using System.Configuration;

      using System.Data;

      using System.Linq;

      using System.Web;

      using System.Web.Security;

      using System.Web.UI;

      using System.Web.UI.HtmlControls;

      using System.Web.UI.WebControls;

      using System.Web.UI.WebControls.WebParts;

      using System.Xml.Linq;

      using System.IO;

      using System.Security.Principal;

      using System.Runtime.InteropServices;

      public partial class _Default : System.Web.UI.Page

      {

      public const int LOGON32_LOGON_INTERACTIVE = 2;

      public const int LOGON32_PROVIDER_DEFAULT = 0;

      WindowsImpersonationContext impersonationContext;

      [DllImport("advapi32.dll")]

      public static extern int LogonUserA(String lpszUserName,

      String lpszDomain,

      String lpszPassword,

      int dwLogonType,

      int dwLogonProvider,

      ref IntPtr phToken);

      [DllImport("advapi32.dll", CharSet = CharSet.Auto, SetLastError = true)]

      public static extern int DuplicateToken(IntPtr hToken,

      int impersonationLevel,

      ref IntPtr hNewToken);

      [DllImport("advapi32.dll", CharSet = CharSet.Auto, SetLastError = true)]

      public static extern bool RevertToSelf();

      [DllImport("kernel32.dll", CharSet = CharSet.Auto)]

      public static extern bool CloseHandle(IntPtr handle);

      public void Page_Load(Object s, EventArgs e)

      {

      if (impersonateValidUser("lucas", "Workgroup", "lcas"))

      {

      string path = @"//zhehui001/lu";

      foreach (string f in Directory.GetFiles(path))

      {

      Response.Write(f);

      }

      undoImpersonation();

      }

      else

      {

      //Your impersonation failed. Therefore, include a fail-safe mechanism here.

      }

      }

      private bool impersonateValidUser(String userName, String domain, String password)

      {

      WindowsIdentity tempWindowsIdentity;

      IntPtr token = IntPtr.Zero;

      IntPtr tokenDuplicate = IntPtr.Zero;

      if (RevertToSelf())

      {

      if (LogonUserA(userName, domain, password, LOGON32_LOGON_INTERACTIVE,

      LOGON32_PROVIDER_DEFAULT, ref token) != 0)

      {

      if (DuplicateToken(token, 2, ref tokenDuplicate) != 0)

      {

      tempWindowsIdentity = new WindowsIdentity(tokenDuplicate);

      impersonationContext = tempWindowsIdentity.Impersonate();

      if (impersonationContext != null)

      {

      CloseHandle(token);

      CloseHandle(tokenDuplicate);

      return true;

      }

      }

      }

      }

      if (token != IntPtr.Zero)

      CloseHandle(token);

      if (tokenDuplicate != IntPtr.Zero)

      CloseHandle(tokenDuplicate);

      return false;

      }

      private void undoImpersonation()

      {

      impersonationContext.Undo();

      }

      }

      補(bǔ)充:局域網(wǎng)、校園網(wǎng)安全維護(hù)方法

      校園網(wǎng)絡(luò)分為內(nèi)網(wǎng)和外網(wǎng),就是說(shuō)他們可以上學(xué)校的內(nèi)網(wǎng)也可以同時(shí)上互聯(lián)網(wǎng),大學(xué)的學(xué)生平時(shí)要玩游戲購(gòu)物,學(xué)校本身有自己的服務(wù)器需要維護(hù);

      在大環(huán)境下,首先在校園網(wǎng)之間及其互聯(lián)網(wǎng)接入處,需要設(shè)置防火墻設(shè)備,防止外部攻擊,并且要經(jīng)常更新抵御外來(lái)攻擊;

      由于要保護(hù)校園網(wǎng)所有用戶的安全,我們要安全加固,除了防火墻還要增加如ips,ids等防病毒入侵檢測(cè)設(shè)備對(duì)外部數(shù)據(jù)進(jìn)行分析檢測(cè),確保校園網(wǎng)的安全;

      外面做好防護(hù)措施,內(nèi)部同樣要做好防護(hù)措施,因?yàn)橛械膶W(xué)生電腦可能帶回家或者在外面感染,所以內(nèi)部核心交換機(jī)上要設(shè)置vlan隔離,旁掛安全設(shè)備對(duì)端口進(jìn)行檢測(cè)防護(hù);

      內(nèi)網(wǎng)可能有ddos攻擊或者arp病毒等傳播,所以我們要對(duì)服務(wù)器或者電腦安裝殺毒軟件,特別是學(xué)校服務(wù)器系統(tǒng)等,安全正版安全軟件,保護(hù)重要電腦的安全;

      對(duì)服務(wù)器本身我們要安全server版系統(tǒng),經(jīng)常修復(fù)漏洞及更新安全軟件,普通電腦一般都是撥號(hào)上網(wǎng),如果有異常上層設(shè)備監(jiān)測(cè)一般不影響其他電腦。做好安全防范措施,未雨綢繆。


    asp.net實(shí)現(xiàn)訪問局域網(wǎng)共享目錄下文件教程相關(guān)文章:

    1.如何設(shè)置局域網(wǎng)共享文件夾和訪問共享文件夾

    2.局域網(wǎng)資源共享的實(shí)現(xiàn)的方法

    3.公司局域網(wǎng)內(nèi)怎樣查看其它電腦共享的文件

    4.局域網(wǎng)共享提示沒有權(quán)限訪問怎么辦

    5.局域網(wǎng)怎么共享電影文件

    4051356