麻煩解釋一個 以下添加郵件帳號和NT帳號的含義
ExchangeAcctLib.AcctMgmt objAcct = new MSExchangeAcctLib.AcctMgmtClass();
                        
object obSID;
object obSD;
string strDCT = "2A864886F7140501";objAcct.GetSidFromName(strDomain,strUsername,out obSID);
objMailbox.Properties["Assoc-NT-Account"].Add(obVal);
objAcct.GenerateSecDescriptor(strDomain,strUsername, out obSD);
objMailbox.Properties["NT-Security-Descriptor"].Add(obSD);
objMailbox.Properties["Deliv-Ext-Cont-Types"].Add(strDCT);
objMailbox.CommitChanges();
objMailbox.Close();用以下程式實現的功能是點擊BUTTON 會增加一個賬號
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using MSExchangeAcctLib;
using   System.DirectoryServices;
namespace exchangetest
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
/// 
public class WebForm1 : System.Web.UI.Page
{   
protected System.Web.UI.WebControls.Button Button1;
       public  MSExchangeAcctLib.AcctMgmt objAcct = new MSExchangeAcctLib.AcctMgmtClass();
public object obSID;
public object obSD;
public string strDCT = "2A864886F7140501";
private void Button1_Click(object sender, System.EventArgs e)
{

    objAcct.NtAccountCreate("utpcb","testtest","123","","5310PC");

}
 
    private void Page_Load(object sender, System.EventArgs e)
{
} #region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.

InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{    
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load); }
#endregion
}
}出現以下錯誤
Server Error in '/exchangetest' Application.
--------------------------------------------------------------------------------存取被拒。 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.UnauthorizedAccessException: 存取被拒。 ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user. To grant ASP.NET write access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.Source Error: 
Line 33:  {
Line 34: 
Line 35:     objAcct.NtAccountCreate("utpcb","testtest","123","","5310PC");
Line 36: 
Line 37:  }
 Source File: c:\inetpub\wwwroot\exchangetest\webform1.aspx.cs    Line: 35 Stack Trace: 
[UnauthorizedAccessException: 存取被拒。]
   MSExchangeAcctLib.AcctMgmtClass.NtAccountCreate(String bstrDomain, String bstrUserLogin, String bstrPassword, String bstrUserComment, String bstrLocalGroup) +0
   exchangetest.WebForm1.Button1_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\exchangetest\webform1.aspx.cs:35
   System.Web.UI.WebControls.Button.OnClick(EventArgs e)
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
   System.Web.UI.Page.ProcessRequestMain() 
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET Version:1.1.4322.2032 請問 我加帳號的程式還要加些什麽?WEBCONFIG文件要加什麽嗎?? 這個網站要建立在EXCHANGE服務器上才可以實現的嗎?/謝謝   等高人

解决方案 »

  1.   

    按照提示,给aspnet帐号增加权限,调试的话,直接“完全”“写入”什么的全都加上
      

  2.   

    是的阿 aspnet帐号增加权限 怎麽增加權限阿?/
      

  3.   

    直接把ASPNET帐号加入到管理员组。
      

  4.   

    把ASPNET帐号加入到管理员组。
     是哪個組呢?/是EXCHANGE服務器還是  別的什麽啊 ?? 謝謝
      

  5.   

    Administrators
     我知道!  是哪個機器上的 ?/
    還是EXCHANG的 管理員群組?
      

  6.   

    你的Web和Exchange不是在同一台服务器上吗??
      

  7.   

    不是的 我們公司有ECHANGE EIP  ERP  ERPSERVER DNS 服務器! 你要建立 哪個帳號呢??
      

  8.   

    你說應該怎麽做呢??有開發過用ASP網頁添加帳戶NT 和EMALI的嗎
      

  9.   

    NT账号的有做过,我的做法是在连接目标机器的同时登录那台机器。连接AD的连接字符串可以包含用户名和密码。
      

  10.   

    public DirectoryEntry (
    string path,
    string username,
    string password
    )
    这个就是NT帐号的操作类的构造函数。
    不知道对你有没有启发!
      

  11.   

    现在打个比方:
    应用程序在机器A,现在要操纵机器B上的AD,那么我们要包含的用户名和密码就是机器B上的具有管理员权限的用户名和密码。
      

  12.   

    首先要謝謝你
    我們使用的是域對吧
    你用的是這個嗎? MSExchangeAcctLib
    還有 我們這個賬號是加入域的所有機器都能登陸!  我要 作的網頁應用程序放在服務器上
     所有通過網頁訪問的機器上能運行 服務器上的網頁 通過這個網頁添加EXCHANGE帳戶 和EMALI 帳號  
      謝謝你 ! 這個能具體說一下你的做法嗎??