I'm trying to get the description field for a computer account. I'm using VBA inside of Excel. Here's the code, simplified as much as I am able to:
Sub xx() MsgBox (x("CN=ComputerName,OU=OU1Name,OU=OU2Name,DC=CompanyName,DC=com")) End Sub Function x(strObjectDN As String) As Boolean Dim CurrentDate As String Dim strDate As String Dim objComputer As Object CurrentDate = Format(Now(), "yyyy-mm-dd") Set objComputer = GetObject("LDAP://" & strObjectDN) MsgBox (objComputer.Description) objComputer.Description = "Disabled: " & CurrentDate MsgBox (objComputer.Description) ' Clear objects 'Set objComputer = Nothing x=true End Function ' MoveADObjectToDisabledOU
When I run it, the first msgbox shows empty and the second one shows the change. However, after the function completes, the computer account's description field is empty again. It works with the same results whether I clear or don't clear the computer object at the end.
I think I'm missing some kind of "commit changes" type of thing, but I can't figure out what. Does anybody know a way to get AD to hold onto the value I submitted?
NOTE: I would prefer to use early binding during code creation, but I have been totally unable to find anything close to what I want using IADS or ADODB or something like that. Any suggestions would be appreciated in this area, too. I might need to know the reference I'll need if you suggest something.
Thank you!
Jim