基本上,我正在创建一个小脚本来更新AD属性(对于超级用户而不是管理员)。
我有很多属性,但我需要一个自定义字段,以便用户可以键入AD属性,然后通过LDAP查询搜索它并使用objUser显示。
以下是代码:
Do While z = True
attrchoice = InputBox("Please enter the custom attribute you wish to edit", "Custom Attribute")
MsgBox "You have selected " & objUser.+attrchoice, vbOKOnly+vbInformation, objUser.displayName
On Error Resume Next
If Err.Number <> 0 Then
MsgBox "Error!" & vbCrlf & "Attribute cannot be found, please try again", vbOKOnly+vbExclamation, "Error"
Else
z = false
End If
On Error Goto 0
Loop
如您所见,我已经尝试过做objUser。属性部分有几种不同的方式 - 但我只是不确定如何使用用户输入的字符串。
在该自定义字段中,用户可以输入“mail”,代码运行将是objUser.mail - 这有意义吗?
如果您需要更多信息,请说明。
显然,我已经在脚本中进一步设置了我的对象,脚本还有其他部分。一切正常,例如:
telchoice = MsgBox("User's current telephone number is " & objUser.telephoneNumber & vbCrlf & vbCrlf & _
"Do you want to change the user's telephone number?", vbYesNo+vbQuestion, objUser.displayName)
If telchoice = 6 Then
newtel = InputBox("Please enter the new telephone number", "Telephone Number", objUser.telephoneNumber)
If Not adoRecord.EOF Then
On Error Resume Next
objUser.Put "telephoneNumber", newtel
objUser.SetInfo
On Error Goto 0
End If
MsgBox "User's new telephone number is now " & objUser.telephoneNumber, vbOKOnly+vbInformation, objUser.displayName
End If
答案 0 :(得分:0)