首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

与EXCHANGE有关 會的絕對是高人解决方法

2012-01-24 
与EXCHANGE有关會的絕對是高人麻煩解釋一個以下添加郵件帳號和NT帳號的含義ExchangeAcctLib.AcctMgmtobjAc

与EXCHANGE有关 會的絕對是高人
麻煩解釋一個   以下添加郵件帳號和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服務器上才可以實現的嗎?/謝謝       等高人



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

[解决办法]
帮LZ顶
[解决办法]
顶下再说.
[解决办法]
學一學
[解决办法]
直接把ASPNET帐号加入到管理员组。
[解决办法]
帐号名字就是ASPNET!
[解决办法]
管理员组就是:Administrators
[解决办法]
你的Web和Exchange不是在同一台服务器上吗??
[解决办法]
幫你 頂一頂 等高手來學習哈哈
[解决办法]
NT账号的有做过,我的做法是在连接目标机器的同时登录那台机器。连接AD的连接字符串可以包含用户名和密码。
[解决办法]
public DirectoryEntry (
string path,
string username,
string password
)
这个就是NT帐号的操作类的构造函数。
不知道对你有没有启发!
[解决办法]
现在打个比方:
应用程序在机器A,现在要操纵机器B上的AD,那么我们要包含的用户名和密码就是机器B上的具有管理员权限的用户名和密码。

热点排行