如何在 Java 中获取 Windows 域
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6111380/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to get Windows Domains in Java
提问by user489041
I have some Windows PC's. I need to get the Windows domains available to this PC for logins. Any ideas?
我有一些 Windows PC。我需要获取可用于此 PC 的 Windows 域以进行登录。有任何想法吗?
回答by moralejaSinCuentoNiProverbio
This only work if the USERDOMAIN
is defined as an environment variable. I read in http://www.wilsonmar.com/1envvars.htmthat %USERDOMAIN%
is the User Domain Name.
这仅在USERDOMAIN
被定义为环境变量时才有效。我在http://www.wilsonmar.com/1envvars.htm中读到%USERDOMAIN%
了用户域名。
If %USERDOMAIN%
is the User Domain Name use this:
如果%USERDOMAIN%
是用户域名,请使用:
String UserDomainName = System.getenv("USERDOMAIN");
回答by Sean Patrick Floyd
As suggested by the answer to this question, ActiveDirectory
is an LDAP server. Here's an article on how to use it with Java.
正如这个问题的答案所建议的那样,ActiveDirectory
是一个 LDAP 服务器。这是一篇关于如何在 Java 中使用它的文章。
回答by Chip McCormick
Use WAFFLE. It support 'enumerating Active Directory domains and domain information.'
使用华夫饼。它支持“枚举 Active Directory 域和域信息”。