在.net 4.0 Web应用程序上升级Active Directory效果

问题描述

我们有一个运行各种.NET框架的Web应用程序混合环境。这些Web应用程序从.NET 4.0开始面向.NET,然后从那里开始。该代码是遗留的ASP.NET Webforms,没有MVC。我写的一些较新的东西可以在.NET Core上运行,而我也不用担心这些代码

基础架构管理员已表明计划将Active Directory从2012 R2升级到2019。我是否应该期待任何重大的兼容性问题?据我所知,所有代码都依赖于System.DirectoryServices的目标框架版本。

执行搜索代码主要如下:

public void SearchByFilter(string filter)
    {
        if (String.IsNullOrEmpty(filter))
            return;

        DirectoryEntry de = new DirectoryEntry("LDAP://DC=company,DC=net");
        DirectorySearcher ds = new DirectorySearcher(de);
        SearchResultCollection src;

        ds.Filter = filter;
        src = ds.FindAll();

        if (src.Count == 1)
        {
            this.searchResult = src[0];
        }

        PopulateFields();
    }

    /// <summary>
    /// Sets all the class properties
    /// </summary>
    public void PopulateFields()
    {
        if (this.searchResult == null)
        {
            this.m_FirstName = "UnkNown";
            this.m_LastName = "User";
        }
        else
        {
            this.m_SID = this.GetField("objectSid");
            this.m_Name = this.GetField("displayName");
            this.m_Email = this.GetField("mail");
            this.m_Title = this.GetField("title");
            this.m_LoginName = this.GetField("samaccountname");
            this.m_FirstName = this.GetField("givenname");
            this.m_LastName = this.GetField("sn");
            this.m_Initials = this.GetField("intials");
            this.m_Description = this.GetField("description");
            this.m_Telephone = this.GetField("telephoneNumber");
        }
    }

上面的代码并不完整,但是代表了查询AD的代码。还有其他查询AD的方式,但是以上内容代表了我们在自定义Web应用程序中运行的代码的大约80%。上面代码中的参数“ filter”可以获得两种样式的过滤器

  1. “(&&(objectClass = user)(objectCategory = user)(objectSid =” + SID +“))”

  2. string [] userParts = principal.Identity.Name.Split(new Char [] {'\'}); SearchByFilter(“(&(objectClass = user)(objectCategory = user)(samaccountname =” + userParts [1] +“))”);

我要感谢那些具有与上面列出的经验类似的经验并愿意分享他们自己升级而获得的结果的人。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)