首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >支持Windows Server 2016?

支持Windows Server 2016?
EN

Stack Overflow用户
提问于 2018-10-11 10:13:17
回答 2查看 121关注 0票数 0

我有一个Winform客户端,它使用Windows Active Directory获取当前Windows帐户名。

是否有任何方法可以知道此解决方案是否可以在不设置新的Windows Server 2016的情况下使用?

客户端代码

代码语言:javascript
复制
            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;
        }
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2018-10-24 07:43:50

我不得不像预期的那样在2016上设置一个测试,我的AD集成工作也一样好。

票数 0
EN

Stack Overflow用户

发布于 2018-10-16 12:48:12

从历史上看,微软在向后兼容方面相当谨慎。这就是为什么您仍然可以在Windows 10中运行DOS程序的原因。

对于AD,它们通常不会删除功能。他们只会加进去。看一看这篇文章,看看AD for Server 2016中的新内容:https://learn.microsoft.com/en-us/windows-server/identity/whats-new-active-directory-domain-services

我希望所有这些都能与运行在Server 2016上的AD一起工作。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52757528

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档