DirectoryEntry DirEntry;  
  
DirEntry = new DirectoryEntry(this.AdsPath);  
  
DirEntry.UsePropertyCache=true;  
  
DirEntry.Invoke("ChangePassword",new object[]{sOldPassword,sNewPassword});  
  
DirEntry.CommitChanges();  

解决方案 »

  1.   

    Dim DirEntry As DirectoryEntry 
    DirEntry = New DirectoryEntry (Me.AdsPath) 
    DirEntry.UsePropertyCache = True 
    DirEntry.Invoke("ChangePassword", New Object() {sOldPassword, sNewPassword}) 
    DirEntry.CommitChanges()
      

  2.   

    首先多謝孟子E章的回答,我下面用的這樣的代碼出錯,請幫忙看看:Dim de As DirectoryEntry = New DirectoryEntry("LDAP://kf_domain/CN=張三,OU=資訊部,OU=Domain Controllers,DC=ds,DC=dsgroup,DC=com", "administrator", "ds2345", AuthenticationTypes.Secure)
            Response.Write(de.Guid.ToString())
            de.UsePropertyCache = True
            de.Invoke("ChangePassword", New Object() {"ds2123", "ds2222"})這段代碼的錯誤信息是:
    無法從網域控制站讀取設定資訊。可能是因為電腦無法使用,或是存取被拒絕。 
    描述: 在執行目前 Web 要求的過程中發生未處理的例外情形。請檢閱堆疊追蹤以取得錯誤的詳細資訊,以及在程式碼中產生的位置。 例外詳細資訊: System.Runtime.InteropServices.COMException: 無法從網域控制站讀取設定資訊。可能是因為電腦無法使用,或是存取被拒絕。原始程式錯誤: 在執行目前 Web 要求期間,產生無法處理的例外狀況。如需有關例外狀況來源與位置的資訊,可以使用下列的例外狀況堆疊追蹤取得。  堆疊追蹤: 
    [COMException (0x80070547): 無法從網域控制站讀取設定資訊。可能是因為電腦無法使用,或是存取被拒絕。][TargetInvocationException: 引動過程的目標傳回例外狀況。]
       System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters) +0
       System.RuntimeType.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters) +473
       System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args) +29
       System.DirectoryServices.DirectoryEntry.Invoke(String methodName, Object[] args) +106
       communication.index.Page_Load(Object sender, EventArgs e) +891
       System.Web.UI.Control.OnLoad(EventArgs e) +67
       System.Web.UI.Control.LoadRecursive() +35
       System.Web.UI.Page.ProcessRequestMain() +731