我在网站上收到错误,我使用Windows身份验证.
奇怪的事情:
这是我在日志邮件中得到的:
来源:System.DirectoryServices
消息:服务器无法运行.
跟踪:
在System.DirectoryServices.DirectoryEntry.Bind(布尔throwIfFail)
在System.DirectoryServices.DirectoryEntry.Bind()
在System.DirectoryServices.DirectoryEntry.get_AdsObject()
在System.DirectoryServices.DirectorySearcher.FindAll(布尔findMoreThanOne)
在的System.DirectoryServices
.DirectorySearcher.FindOne ()在Smarthouse.Labs.DataAccess.UserListManager.SaveUser(String windowsUserName)
这是我实现DirectorySearch的方式:
private void SaveUser(string windowsUserName)
{
string[] domainAndUser = windowsUserName.Split('\\');
string domain = domainAndUser[0];
string username = domainAndUser[1];
DirectoryEntry entry = new DirectoryEntry("LDAP://" + domain);
DirectorySearcher search = new DirectorySearcher(entry);
try
{
// Bind to the native AdsObject to force authentication.
search.Filter = "(SAMAccountName=" + username + ")";
search.PropertiesToLoad.Add("cn");
search.PropertiesToLoad.Add("sn");
search.PropertiesToLoad.Add("givenName");
search.PropertiesToLoad.Add("mail");
SearchResult result = search.FindOne();
if (result == null)
{
throw new Exception("No …
Run Code Online (Sandbox Code Playgroud) asp.net directoryservices active-directory windows-authentication
我想要使用斜杠而不是反斜杠,因为我的应用程序与 ftp 通信,不允许反斜杠作为目录分隔符。
是否有任何快捷方式/配置而无需编写自己的方法?