Поддержите Windows Server 2016 Active Directory?

У меня есть клиент Winform, который использует Windows Active Directory для получения текущего имени учетной записи Windows.

Есть ли способ узнать, будет ли это решение работать с новой Windows Server 2016 Active Directory, не настраивая его?

Код клиента

            public string GetCurrentActiveDirectoryAccountName()
            {
                var windowsName = WindowsIdentity.GetCurrent().Name;
                var index = windowsName.LastIndexOf("\\");
                if (index > 0)
                    windowsName = windowsName.Substring(index + 1);

                return windowsName;
            }

        public void AuthenticateActiveDirectoryAccount(string username, string password)
        {
            //Hidden code to setup variables 

            if (ADUserName.Length > 0)
                context = new PrincipalContext(ContextType.Domain, ADServer, ADUserName, ADUserPassword);
            else
                context = new PrincipalContext(ContextType.Domain, ADServer);

            using (context)
            {
                if (!context.ValidateCredentials(account, password))
                    //Hidden code to throw exception
            }
        }

        public string CheckActiveDirectoryAccount(string account)
        {
            ///Hidden code to setup variables

            if (ADUserName.Length > 0)
                context = new PrincipalContext(ContextType.Domain, ADServer, null, ADUserName, ADUserPassword);
            else
                context = new PrincipalContext(ContextType.Domain, ADServer);

            using (context)
            {
                if ((user = UserPrincipal.FindByIdentity(context, account)) == null)
                {
                    if (account.Contains("\\"))
                    {
                        userPrincipalNameList = user.UserPrincipalName.Split('\\').ToList();

                        if (userPrincipalNameList.Count > 0)
                            user = UserPrincipal.FindByIdentity(context, userPrincipalNameList[0]);
                    }
                }

                if (user != null)
                {
                    using (user)
                    {
                        userAccount = user.SamAccountName;
                        return userAccount.ToLower();
                    }
                }
            }
            return string.Empty;
        }

person Banshee    schedule 11.10.2018    source источник


Ответы (2)


Microsoft исторически очень осторожно относилась к обратной совместимости. Вот почему вы все еще можете запускать программы DOS в Windows 10.

В AD они обычно не удаляют функции. Они их только добавляют. Ознакомьтесь с этой статьей, чтобы узнать, что нового в AD для Server 2016: https://docs.microsoft.com/en-us/windows-server/identity/whats-new-active-directory-domain-services

Я ожидал, что все это будет работать с AD, работающим на Server 2016.

person Gabriel Luci    schedule 16.10.2018

Мне пришлось настроить тест с Microsoft Windows Server 2016, как и ожидалось, моя интеграция с AD работает так же хорошо.

person Banshee    schedule 24.10.2018