
Visual Basic 2008 and Active Directory computer description modifications
ok, it appears that i have run into a spot that i am not able to
figure out on my own. Let me first say that i have hobbled together
this SUB from things i found on the internet and tutorials. Here is my
issue...I can search AD for the description of the computer and
display it out but am unable to figure out if the
" results.Getdirectoryentry().properties("description").value =
"Turek, Brett - Dell Laptop"
results.CommitChanges()
results.Close()
"
part will actually do what i want, change the description in AD of the
computer. Can anyone look this over and let me know if i am on the
right path? How about some examples of how to change things in AD?
*******************
Complete Code:
*******************
Public Sub Button5_Click(ByVal sender As Object, ByVal e As EventArgs)
Handles Button5.Click
'Rename Description
Dim userID = "DOMAIN\USERNAME"
Dim password = "PASSWORD"
Dim rootEnty As New DirectoryEntry("LDAP://
OU=Computers,OU=City,OU=MAR,OU=Customer,DC=us,DC=company,DC=com",
userID, password)
Dim Searcher As New DirectorySearcher(rootEnty)
Searcher.Filter = "(CN=computerName)"
results = Searcher.FindOne()
'For Each result In results
item =
results.GetDirectoryEntry().Properties("description").Value
'Next
MsgBox(item) ' output to check that look up worked.
results.Getdirectoryentry().properties("description").value =
"Turek, Brett - Dell Laptop"
results.CommitChanges()
results.Close()
End Sub