拆分阵列并获得一定位置
我想获得当前计算机的杰出名称。这有效:
Dim objSysInfo, objComp, arr, UCID
Set objSysInfo = CreateObject("ADSystemInfo")
' Current computer
Set objComp = GetObject("LDAP://" & objSysInfo.ComputerName)
DN = objComp.distinguishedName
但是我只想将杰出名称的一部分保存在一个新变量中。
例如:杰出的名称是“ OU = X,OU = Y, OU = that ,dc = a,dc = b,dc = c”
i i仅需要“ that” 对于我的变量。它总是从右侧开始的第四位。
我该怎么做?我从此开始...
OU= Split (DN, ",")
非常感谢!!!
I want to get the distinguished name of the current computer. That works:
Dim objSysInfo, objComp, arr, UCID
Set objSysInfo = CreateObject("ADSystemInfo")
' Current computer
Set objComp = GetObject("LDAP://" & objSysInfo.ComputerName)
DN = objComp.distinguishedName
But I only want to save a part of the distinguished name in a new variable.
For example: The distinguished name is "OU=X, OU=Y, OU=THAT, DC=A, DC=B, DC=C"
I just need "THAT" for my variable. It is always on the fourth position beginning from the right side.
How do I do this? I started with this...
OU= Split (DN, ",")
Thank you very much!!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您检查 Split 的文档,您将看到它返回一个数组(从零开始的索引)。因此,您需要在
,
上拆分并获取第三个元素(索引 2),然后在=
上拆分该结果并获取第二个元素(索引 1):If you check the documentation for Split, you will see that it returns an array (zero-based index). Therefore, you need to split on
,
and get the third element (index 2), and then split that result on=
and get the second element (index 1):