[英]ASP.NET MVC application querying Active Directory
I have a scenario where I want to search Active Directory (AD) for users. 我有一种情况,我想在Active Directory(AD)中搜索用户。 Basically I want to query the AD based on a substring
基本上我想基于子字符串查询广告
Example - Query string Jimmy should return all the users whose name start with Jimmy. 示例-查询字符串Jimmy应该返回名称以Jimmy开头的所有用户。
string userName = "Jimmy"
DirectorySearcher searcher = new DirectorySearcher(entry);
searcher.SearchScope = SearchScope.Subtree;
searcher.PropertiesToLoad.Add("mail");
searcher.PropertiesToLoad.Add("displayname");
searcher.PropertiesToLoad.Add("alias");
searcher.SizeLimit = 5;
searcher.Filter = "(&(objectClass=user)(displayname=" + userName + "*))";
SearchResultCollection searchResults = searcher.FindAll();
This snippet does not yield any results at all from the web application. 该代码段根本不会从Web应用程序中产生任何结果。 However this snippet works from on a console application.. I have not added any references in the web.config file at the moment.
但是,此代码段可在控制台应用程序上运行。.目前,我尚未在web.config文件中添加任何引用。
Am I missing out some configuration for the communication between ASP.NET MVC application and Active Directory to happen ? 我是否缺少一些ASP.NET MVC应用程序和Active Directory之间进行通信的配置?
如果它从您的控制台应用程序而不是Web应用程序运行,则听起来像配置差异
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.