从来自python的web api请求获取活动目录id

2024-09-30 22:25:04 发布

您现在位置:Python中文网/ 问答频道 /正文

我可以从webapi请求中获得IP地址,但是我想知道是否有一种方法可以从python发出的webapi请求中获取activedirectory或目录服务id?在

下面将回显用户的IP地址。如何从python打一个电话让我回显他们的广告或DS id?在

 public HttpResponseMessage Get(string system)
 {
            // validate ip address
            string ip = HttpContext.Current.Request.UserHostAddress;

return new HttpResponseMessage() 
            { 
                Content = new StringContent(ip)
            };
}

Tags: 方法用户ip目录idnewgetstring
1条回答
网友
1楼 · 发布于 2024-09-30 22:25:04

这是你想要的吗?(必须添加对的引用System.DirectoryServices.AccountManagement.dll)

public HttpResponseMessage Get(string system)
{

  string domain = new System.DirectoryServices.AccountManagement.PrincipalContext(ContextType.Domain).ConnectedServer; 

  return new HttpResponseMessage()  {   Content = new StringContent(domain )   };
}

相关问题 更多 >