System.Web.Security.ActiveDirectoryMembershipProvider的ASP.NET问题:网络地址无效

时间:2016-08-22 11:44:20

标签: asp.net azure iis active-directory ldap

我有一个运行Windows Server 2008的Azure VM,其中Active Directory实例列出了测试用户。我也有Azure SQL测试数据库。我想从我在本地PC的IIS中运行的ASP.NET MVC应用程序访问此数据库和AD。

我能够以Azure VM AD中列出的用户身份登录(ADRoleConnectionString正在运行)但是当我尝试获取有关用户的其他信息时,System.Web.Security.ActiveDirectoryMembershipProvider Initialize会引发错误此应用程序在数据库中引用。

堆栈追踪:

  

---> System.Runtime.InteropServices.COMException:网络地址无效。

     

在System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)      在System.DirectoryServices.ActiveDirectory.DirectoryContext.IsContextValid(DirectoryContext context,DirectoryContextType contextType)      ---内部异常堆栈跟踪结束---      在System.DirectoryServices.ActiveDirectory.DirectoryContext.IsContextValid(DirectoryContext context,DirectoryContextType contextType)      在System.DirectoryServices.ActiveDirectory.DirectoryContext.isServer()      在System.DirectoryServices.ActiveDirectory.Domain.GetDomain(DirectoryContext context)      在System.Web.Security.DirectoryInformation.InitializeDomainAndForestName()      在System.Web.Security.ActiveDirectoryMembershipProvider.Initialize(String name,NameValueCollection config)      在System.Web.Configuration.ProvidersHelper.InstantiateProvider(ProviderSettings providerSettings,Type providerType)      ---内部异常堆栈跟踪结束---      在System.Web.Configuration.ProvidersHelper.InstantiateProvider(ProviderSettings providerSettings,Type providerType)      在System.Web.Configuration.ProvidersHelper.InstantiateProviders(ProviderSettingsCollection configProviders,ProviderCollection providers,Type providerType)      在System.Web.Security.Membership.InitializeSettings(Boolean initializeGeneralSettings,RuntimeConfig appConfig,MembershipSection设置)      在System.Web.Security.Membership.Initialize()      在System.Web.Security.Membership.get_Provider()

连接字符串是:

<connectionStrings>
<add name="ADConnectionString" connectionString="LDAP://address-to-azure:389/OU=users,OU=myservice,DC=servicedomain,DC=com" />
<add name="ADRoleConnectionString" connectionString="LDAP://address-to-azure:389/OU=users,OU=myservice,DC=servicedomain,DC=com" />

...

<add name="MY_ADMembershipProvider" type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" enableSearchMethods="true" connectionStringName="ADConnectionString" attributeMapUsername="sAMAccountName" connectionProtection="None" connectionUsername="testUser@servicedomain.com" connectionPassword="password" applicationName="MyTestApp" />

当我将应用程序部署到Azure VM IIS但不能从我的本地PC IIS部署时,这种方法可行。我有端口389打开TCP和UDP,我能够使用Active Directory资源管理器工具列出查看用户没有问题。我的本地活动目录实例(localhost:389)也没有问题。

  • 我试图更改IIS应用程序池标识,但它没有帮助。

  • 如果我将ADConnectionString路径OU = users,OU = myservice,DC = servicedomain,DC = com更改为AD中不存在的内容,则会收到错误:连接字符串中指定的容器不存在。这证明网络地址是有效的,因为它知道Azure AD路径存在。

我完全没有想法可能是什么问题。有谁知道可能是什么问题?

0 个答案:

没有答案