Problem saving values to Active Directory

  • Thread starter Thread starter robin9876
  • Start date Start date
R

robin9876

When using the code below the following error occurs when the
commitchanges line is run. What is causing this problem and how can the
data be saved back?

System.DirectoryServices.DirectoryServicesCOMException was unhandled
ErrorCode=-2147016693
Message="The attribute syntax specified to the directory service is
invalid. (Exception from HRESULT: 0x8007200B)"
Source="System.DirectoryServices"


Sample snippet of code used.

searcher.PropertiesToLoad.AddRange(New String() { _
"description",
"PhysicalDeliveryOfficeName", "Title", _
"extensionAttribute2",
"extensionAttribute4", "extensionAttribute5", _
"extensionAttribute1", "roomNumber",
"telephoneNumber", _
"roomNumber", "telephoneNumber",
"company" _
})

Dim srResults As SearchResultCollection
Dim srResult As SearchResult

' Get all matching details
srResults = searcher.FindAll
Dim onUser As New System.DirectoryServices.DirectoryEntry

For Each srResult In srResults
onUser = srResult.GetDirectoryEntry()

onUser.Properties("description").Value =
NZ(txtDescription.Text)
onUser.Properties("PhysicalDeliveryOfficeName").Value =
NZ(txtOffice.Text)
onUser.Properties("Title").Value = NZ(txtTitle.Text)
onUser.Properties("extensionAttribute2").Value =
cbJobType.SelectedText
onUser.Properties("extensionAttribute4").Value =
NZ(txtSecretQuestion.Text)
onUser.Properties("extensionAttribute5").Value =
NZ(txtSecretAnswer.Text)
onUser.Properties("roomNumber").Value =
NZ(txtRoomNumber.Text)
onUser.Properties("telephoneNumber").Value =
NZ(txtTelephoneNumber.Text)
onUser.Properties("company").Value =
cbOrganisation.SelectedText

onUser.CommitChanges()
 
Back
Top