小编Tai*_*har的帖子

System.DirectoryServices - 服务器无法运行

我在网站上收到错误,我使用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

15
推荐指数
1
解决办法
3万
查看次数

如何在 Windows 环境中强制 System.IO.Path.GetDirectoryName(string path) 使用 /

我想要使​​用斜杠而不是反斜杠,因为我的应用程序与 ftp 通信,不允许反斜杠作为目录分隔符。

是否有任何快捷方式/配置而无需编写自己的方法?

.net asp.net

5
推荐指数
1
解决办法
3060
查看次数