2014-11-19 2 views
0

기본적으로 AD 속성을 업데이트하는 작은 스크립트를 만듭니다 (관리자가 아닌 수퍼 유저 용).Object 메서드로 문자열 사용

많은 특성이 있지만 사용자가 AD 특성을 입력 할 수 있도록 사용자 지정 필드가 필요합니다. 그러면 LDAP 쿼리에서 검색하여 objUser를 사용하여 표시합니다. 나는 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 

당신이 볼 수 있듯이 : 여기

는 코드입니다. 속성은 몇 가지 다른 방식으로 제공됩니다. 그러나 사용자가 입력 한 문자열을 사용하는 방법을 모르겠습니다.

사용자 정의 필드에서 사용자는 "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

Get() 기능 만 사용하면됩니다.

strValue = objUser.Get(attrchoice) 

나중에 Put() 함수를 사용하여 속성에 값을 할당하고 있습니다. 그것은 비슷하지만 반대입니다.

+0

그건 하나의 본드입니다! 고마워요. 모두 일하고 있습니다. 오늘 Get()에 관해 배웠습니다. :) – ElliotBath

관련 문제