![](/img/trans.png)
[英]Changed the domain on windows 7 machine. How can I revert back to original Domain name?
[英]How can I check the name of the Azure AD domain that a Windows machine is joined to?
我目前正在使用DsRoleGetPrimaryDomainInformation API来获取计算机加入的域的名称。 但是,这似乎不适用于Azure AD域,在这种情况下,此API返回空响应。
是否可以在不联系服务器的情况下在本地使用任何其他API来确定计算机要加入到哪个Azure AD域?
找不到实现此目的的API,但是我们可以使用命令Net Config Workstation
(请参阅此处 )获取客户端计算机的实际登录域名。
这是一个使用C#打印相对信息的代码示例:
public static string GetDoaminInfo()
{
Process cmd = new Process();
cmd.StartInfo.FileName = "cmd.exe";
cmd.StartInfo.RedirectStandardInput = true;
cmd.StartInfo.RedirectStandardOutput = true;
cmd.StartInfo.CreateNoWindow = true;
cmd.StartInfo.UseShellExecute = false;
cmd.Start();
cmd.StandardInput.WriteLine("net config workstation");
cmd.StandardInput.Flush();
cmd.StandardInput.Close();
cmd.WaitForExit();
return cmd.StandardOutput.ReadToEnd();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.