当前位置:首页 > 网络编程 > WEB编程 > ASP.net >  通过ASP.net程序创建域帐户故障(1)

 通过ASP.net程序创建域帐户故障(1)

点击次数:20 次 发布日期:2008-11-26 14:07:18 作者:源代码网
源代码网推荐      我曾经成功地使用windows程序成功的创建了一批带邮箱的域帐户,但是,当我把这段代码交给我的一个同事(她负责开发Web应用)迁移到asp.net中后,只能创建域帐户,不能创建邮箱。为什么呢?
源代码网推荐  
源代码网推荐  我们咨询了微软的工程师,他告诉我们,这是由于asp.net的权限不够,我们应该在asp.net模拟用户,这样就可以成功创建。
源代码网推荐  
源代码网推荐  我将微软的相关文章摘录下来:
源代码网推荐  
源代码网推荐  
源代码网推荐  
源代码网推荐  模拟 IIS 验证的帐户或用户
源代码网推荐  
源代码网推荐  若要在收到 ASP.NET 应用程序中每个页的每个请求时模拟 Microsoft Internet 信息服务 (IIS) 身份验证用户,必须在此应用程序的 Web.config 文件中包含 <identity> 标记,并将 impersonate 属性设置为 true。例如:
源代码网推荐  
源代码网推荐  <identity impersonate="true" />
源代码网推荐  
源代码网推荐  
源代码网推荐  为 ASP.NET 应用程序的所有请求模拟特定用户
源代码网推荐  
源代码网推荐  若要为 ASP.NET 应用程序的所有页面上的所有请求模拟特定用户,可以在该应用程序的 Web.config 文件的 <identity> 标记中指定 userName 和 password 属性。例如:
源代码网推荐  
源代码网推荐  <identity impersonate="true" userName="accountname" password="password" />
源代码网推荐  
源代码网推荐  
源代码网推荐  注意:在线程上模拟特定用户的进程的标识必须具有“作为操作系统的一部分”权限。默认情况下,Aspnet_wp.exe 进程在名为 ASPNET 的计算机帐户下运行。不过,此帐户没有模拟特定用户所需的权限。如果您尝试模拟特定用户,则会出现一条错误信息。
源代码网推荐  
源代码网推荐  要解决此问题,请使用下列方法之一:
源代码网推荐  
源代码网推荐  •
源代码网推荐  
源代码网推荐  为 ASPNET 帐户(权限最低的帐户)授予“作为操作系统的一部分”权限。
源代码网推荐  
源代码网推荐  注意:虽然此方法可以解决问题,但 Microsoft 不建议使用此方法。
源代码网推荐  
源代码网推荐  •
源代码网推荐  
源代码网推荐  在 Machine.config 文件的 <processModel> 配置部分中,将运行 Aspnet_wp.exe 进程所使用的帐户更改为 System 帐户。
源代码网推荐  
源代码网推荐  在代码中模拟身份验证用户
源代码网推荐  
源代码网推荐  若要仅在运行代码特定部分时模拟身份验证用户 (User.Identity),您可以使用以下代码。此方法要求身份验证用户标识的类型为 WindowsIdentity。
源代码网推荐  
源代码网推荐  Visual Basic .NET
源代码网推荐  
源代码网推荐  Dim impersonationContext As System.Security.Principal.WindowsImpersonationContext
源代码网推荐  Dim currentWindowsIdentity As System.Security.Principal.WindowsIdentity
源代码网推荐  currentWindowsIdentity = CType(User.Identity, System.Security.Principal.WindowsIdentity)
源代码网推荐  impersonationContext = currentWindowsIdentity.Impersonate()
源代码网推荐  "Insert your code that runs under the security context of the authenticating user here.
源代码网推荐  impersonationContext.Undo()
源代码网推荐  
源代码网推荐  
源代码网推荐  Visual C# .NET
源代码网推荐  
源代码网推荐  System.Security.Principal.WindowsImpersonationContext impersonationContext;
源代码网推荐  impersonationContext =
源代码网推荐  ((System.Security.Principal.WindowsIdentity)User.Identity).Impersonate();
源代码网推荐  //Insert your code that runs under the security context of the authenticating user here.
源代码网推荐  impersonationContext.Undo();
源代码网推荐  
源代码网推荐  
源代码网推荐  Visual J# .NET
源代码网推荐  
源代码网推荐  System.Security.Principal.WindowsImpersonationContext impersonationContext;
源代码网推荐  impersonationContext =
源代码网推荐  ((System.Security.Principal.WindowsIdentity)get_User().get_Identity()).Impersonate();
源代码网推荐  //Insert your code that runs under the security context of the authenticating user here.
源代码网推荐  impersonationContext.Undo();
源代码网推荐  
源代码网推荐  
源代码网推荐  在代码中模拟特定用户
源代码网推荐  
源代码网推荐  若要仅在运行代码特定部分时模拟特定用户,请使用以下代码:
源代码网推荐  
源代码网推荐  
源代码网推荐    做人要厚道,请注明转自酷网动力(www.ASPCOOL.COM)。
源代码网推荐


源代码网供稿.
网友评论 (0)
会员中心
网络编程
本站推荐
网络编程之精华