R
Robin
When using the following ASP.Net code the error "The directory service
cannot perform the requested operation on the RDN attribute of an object."
is displayed when the commit changes is run. What modifications need to be
made to the code to allow it to update the details?
Dim rootDSE As New DirectoryEntry("LDAP://RootDSE")
Dim namingContext As String =
rootDSE.Properties("defaultNamingContext").Value.ToString()
Dim searchRoot As New DirectoryEntry("LDAP://" & namingContext)
Dim searcher As New DirectorySearcher
searcher.SearchRoot = searchRoot
searcher.Filter =
String.Format("(&(objectCategory=person)(objectClass=user)(samAccountName={0
}))", cUser)
searcher.PropertiesToLoad.AddRange(New String() { _
"name", "givenName", "sn", "initials", "personalTitle",
"extensionAttribute1", _
"department", "title", "description", "info", "roomNumber",
_
"telephoneNumber", "mail", "homePostalAddress",
"extensionAttribute2" _
})
Dim result As SearchResult = searcher.FindOne()
Dim onUser As System.DirectoryServices.DirectoryEntry =
result.GetDirectoryEntry
onUser.Properties("name").Value = NZ(tbPreferredName.Text) ' a text
field
' save details back to AD
onUser.CommitChanges()
cannot perform the requested operation on the RDN attribute of an object."
is displayed when the commit changes is run. What modifications need to be
made to the code to allow it to update the details?
Dim rootDSE As New DirectoryEntry("LDAP://RootDSE")
Dim namingContext As String =
rootDSE.Properties("defaultNamingContext").Value.ToString()
Dim searchRoot As New DirectoryEntry("LDAP://" & namingContext)
Dim searcher As New DirectorySearcher
searcher.SearchRoot = searchRoot
searcher.Filter =
String.Format("(&(objectCategory=person)(objectClass=user)(samAccountName={0
}))", cUser)
searcher.PropertiesToLoad.AddRange(New String() { _
"name", "givenName", "sn", "initials", "personalTitle",
"extensionAttribute1", _
"department", "title", "description", "info", "roomNumber",
_
"telephoneNumber", "mail", "homePostalAddress",
"extensionAttribute2" _
})
Dim result As SearchResult = searcher.FindOne()
Dim onUser As System.DirectoryServices.DirectoryEntry =
result.GetDirectoryEntry
onUser.Properties("name").Value = NZ(tbPreferredName.Text) ' a text
field
' save details back to AD
onUser.CommitChanges()