Vbscript - 重用 LDAP 对象?
我正在使用 ADSI Scriptomatic,我注意到这些示例需要用户名 strName
,但我想要执行一整批操作以从 AD 中提取数据并将数据放回。我只是想知道当我提取或放入数据时 objRootDSE 对象会发生什么?
Public Sub createADCommand(Optional strContainer As String)
Set objRootDSE = GetObject("LDAP://rootDSE")
If strContainer = "" Then
Set objItem = GetObject("LDAP://" & _
objRootDSE.Get("defaultNamingContext"))
Else
Set objItem = GetObject("LDAP://cn=" & strName & "," & strContainer & "," & _
objRootDSE.Get("defaultNamingContext"))
End If
End Sub
我问的原因是因为我想重用这个对象(如果它在某种程度上占用内存)。我希望代码尽可能高效。但我不确定 LDAP 是否是一个重型协议?我知道“L”代表“轻量级”:p 但如果我只是想再次重新打开一个对象,我认为关闭它没有任何意义。
I was using ADSI Scriptomatic and I've noticed that these examples require a username strName
, but I want to do a whole batch of operations to both pull data from AD and put data back as well. I was just wondering what happens to the objRootDSE object when I've pulled or put data in it?
Public Sub createADCommand(Optional strContainer As String)
Set objRootDSE = GetObject("LDAP://rootDSE")
If strContainer = "" Then
Set objItem = GetObject("LDAP://" & _
objRootDSE.Get("defaultNamingContext"))
Else
Set objItem = GetObject("LDAP://cn=" & strName & "," & strContainer & "," & _
objRootDSE.Get("defaultNamingContext"))
End If
End Sub
The reason I'm asking is because I want to reuse this object if it's memory intensive in some way. I want the code to be as efficient as possible. But I'm not sure if LDAP is a heavy protocol or not? I know the "L" is for "Lightweight" :p But I see no point in closing an object if I'm just gonna reopen it again.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在这种情况下,LDAP 不相关。相反,您的变量“objItem”存储它收集的所有内容(在本例中为来自 LDAP 的数据)。而且您不必担心将其放回原处,除非您想要更改、删除或添加 LDAP 数据。
In this context, LDAP isn't relevant. Instead, your variable "objItem" is storing whatever it collects (in this case, data from LDAP). And you don't have to worry about putting it back, unless you want to change, remove, or add the LDAP data.