如何在java中获取active directory域名
请告诉我 如何从java获取active directory域名 我试过这个 System.out.println(System.getenv(“USERDOMAIN”); 但我只知道电脑的名字 ====================== 我这样做了如何在java中获取active directory域名,java,Java,请告诉我 如何从java获取active directory域名 我试过这个 System.out.println(System.getenv(“USERDOMAIN”); 但我只知道电脑的名字 ====================== 我这样做了 InetAddress inet=InetAddress.getLocalHost(); InetAddress[]ips=InetAddress.getAllByName(inet.getCanonicalHostName()); userna
InetAddress inet=InetAddress.getLocalHost();
InetAddress[]ips=InetAddress.getAllByName(inet.getCanonicalHostName());
usernameId.setText(System.getProperty(“user.name”);
如果(ips!=null){
对于(int i=0;i
我从中获取ip地址和computername.domainname,尝试检查domainname
环境变量
或者,从中尝试LOGONSERVER
变量
如果这不起作用,我建议直接查看您的环境变量(方向因您运行的Windows版本而异),以找到实际包含您要查找的信息的变量,然后使用该变量。从中,尝试检查域名
环境变量
或者,从中尝试LOGONSERVER
变量
如果这不起作用,我建议您直接查看您的环境变量(方向因您运行的Windows版本而异),以找到实际包含您要查找的信息的变量,然后使用该变量。尝试使用
System.out.println(System.getenv("USERDNSDOMAIN"));
如果这不起作用,您可以(正如James Tanner所说)尝试解析您的系统变量,以找到您想要的:
Map<String, String> envMap = System.getenv();
Iterator iter = envMap.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry<String, String> pair = (Map.Entry<String, String>)iter.next();
System.out.println(pair.getKey() + " = " + pair.getValue());
}
Map envMap=System.getenv();
迭代器iter=envMap.entrySet().Iterator();
while(iter.hasNext()){
Map.Entry对=(Map.Entry)iter.next();
System.out.println(pair.getKey()+“=”+pair.getValue());
}
尝试使用
System.out.println(System.getenv("USERDNSDOMAIN"));
如果这不起作用,您可以(正如James Tanner所说)尝试解析您的系统变量,以找到您想要的:
Map<String, String> envMap = System.getenv();
Iterator iter = envMap.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry<String, String> pair = (Map.Entry<String, String>)iter.next();
System.out.println(pair.getKey() + " = " + pair.getValue());
}
Map envMap=System.getenv();
迭代器iter=envMap.entrySet().Iterator();
while(iter.hasNext()){
Map.Entry对=(Map.Entry)iter.next();
System.out.println(pair.getKey()+“=”+pair.getValue());
}
我没有想到仅仅使用Java以独立于平台的方式列出您的环境变量。聪明。我没有想到仅仅使用Java以独立于平台的方式列出您的环境变量。聪明。