什么是ADSystemInfo的DirectoryServices等价物 [英] What is DirectoryServices Equivalent of ADSystemInfo

查看:304
本文介绍了什么是ADSystemInfo的DirectoryServices等价物的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

在jscript中,我可以执行类似下面的操作,并获取与该用户关联的属性及其值。

In jscript I can do something like below and get at the properties and their values associated with that user.

设置objSysInfo = CreateObject(" ADSystemInfo")

strUserName = objSysInfor.UserName

设置objUser = Getobject(" LDAP://"& strUserName)

blah

blah

Set objSysInfo = CreateObject("ADSystemInfo")
strUserName = objSysInfor.UserName
Set objUser = Getobject ("LDAP://" & strUserName)
blah
blah

要在C#中做到这一点...我工作的很好......但是我找不到与"CreateObject ...."相同的东西。除了引用ActiveDs typlib来检索AD用户名..这看起来有点像黑客...有没有办法做这个没有
的ActiveDs类型库?

To do this in C#...what I've got working is fine...but I couldn't find something equivalent to the "CreateObject...." other than to reference the ActiveDs typlib to retrieve the AD username..which seems like a bit of hack...is there a way to do this without the ActiveDs typelib?

ActiveDs。

 

ADSystemInfoClass
adObject =
new
ADSystemInfoClass ();

ADSystemInfoClass adObject = new ADSystemInfoClass();

 

 

DirectoryEntry
dirEntry =
new
DirectoryEntry " LDAP://"
+ adObject.UserName);

DirectoryEntry dirEntry = new DirectoryEntry("LDAP://" + adObject.UserName);

 

 

foreach string
name
in
dirEntry.Properties.PropertyNames)

foreach(string name in dirEntry.Properties.PropertyNames)

{

 

 

控制台 .WriteLine(name);

Console.WriteLine(name);

 

 

foreach
object
o
in
dirEntry.Properties [name])

foreach (object o in dirEntry.Properties[name])

{

 

 

控制台 。WriteLine(o.ToString());

Console.WriteLine(o.ToString());

}

}

推荐答案

< D> Darn,我讨厌这些未完成的线程!

Darn, I hate these unfinished threads!

我正在尝试使用.net获取工作站的站点名称。我可以在VBS中找到代码

I am trying to get the site name for a workstation using .net. I can find the code in VBS as

设置   objADSysInfo  =  CreateObject( "ADSystemInfo" ) 

WScript.Echo  " ;当前 网站 名称: "  &  objADSysInfo.SiteName 

Set objADSysInfo = CreateObject("ADSystemInfo"
WScript.Echo "Current site name: " & objADSysInfo.SiteName 

...但如果有,我会感到惊讶不是一个可以做得更好的.net类。将VBS翻译成.net对我来说有点神秘。

...but I would be surprised if there was not a .net class that could do it better. Translating VBS to .net is a bit of an enigma for me.

帮助?

这篇关于什么是ADSystemInfo的DirectoryServices等价物的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆