G
Guest
Hello. I am trying to update attributes in LDAP/Active directory from my
application that is written in VB.NET. I am using Directory Services to do
so. I do not get any errors during the execution of the code but directory
is not being updated. I think it has something to do with caching. I do not
understand how directory services library handles it. Can someone please
help. Here is the sample of my code:
Try
mDirectoryEntry.AuthenticationType = AuthenticationTypes.SecureSocketsLayer
mDirectoryEntry.Username = distName
mDirectoryEntry.Password = pwd
mDirectoryEntry.UsePropertyCache = True
Catch ex As Exception
End Try
Dim oSearcher As DirectorySearcher
Dim oSearchResult As SearchResult
Try
oSearcher = New DirectorySearcher(mDirectoryEntry)
oSearcher.Filter = "some filter"
oSearcher.PropertiesToLoad.AddRange(attribute list)
oSearchResult = oSearcher.FindOne()
…
Dim oldValue As String =
oSearchResult.GetDirectoryEntry.Properties(attrList(i))(0)
oSearchResult.GetDirectoryEntry.Properties(attrList(i))(0) = itemValue
oSearchResult.GetDirectoryEntry.CommitChanges()
Catch ex As Exception
Finally
If Not oSearcher Is Nothing Then oSearcher.Dispose()
oSearcher = Nothing
oSearchResult = Nothing
End Try
Can also someone explain me how UsePropertyCache and RefreshCache work?
Thanks in advance for your help.
application that is written in VB.NET. I am using Directory Services to do
so. I do not get any errors during the execution of the code but directory
is not being updated. I think it has something to do with caching. I do not
understand how directory services library handles it. Can someone please
help. Here is the sample of my code:
Try
mDirectoryEntry.AuthenticationType = AuthenticationTypes.SecureSocketsLayer
mDirectoryEntry.Username = distName
mDirectoryEntry.Password = pwd
mDirectoryEntry.UsePropertyCache = True
Catch ex As Exception
End Try
Dim oSearcher As DirectorySearcher
Dim oSearchResult As SearchResult
Try
oSearcher = New DirectorySearcher(mDirectoryEntry)
oSearcher.Filter = "some filter"
oSearcher.PropertiesToLoad.AddRange(attribute list)
oSearchResult = oSearcher.FindOne()
…
Dim oldValue As String =
oSearchResult.GetDirectoryEntry.Properties(attrList(i))(0)
oSearchResult.GetDirectoryEntry.Properties(attrList(i))(0) = itemValue
oSearchResult.GetDirectoryEntry.CommitChanges()
Catch ex As Exception
Finally
If Not oSearcher Is Nothing Then oSearcher.Dispose()
oSearcher = Nothing
oSearchResult = Nothing
End Try
Can also someone explain me how UsePropertyCache and RefreshCache work?
Thanks in advance for your help.