我能够从web api请求中获取IP地址,但我想知道是否有办法从源自python的web api请求中获取活动目录或目录服务ID?
以下内容将回显用户的IP地址。如何从python拨打电话,让我能够回显他们的AD或DS ID?
public HttpResponseMessage Get(string system)
{
// validate ip address
string ip = HttpContext.Current.Request.UserHostAddress;
return new HttpResponseMessage()
{
Content = new StringContent(ip)
};
}
答案 0 :(得分:0)
这是你想要的吗?(你必须添加对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 ) };
}