问题
I have an application that resides on a network drive.
When the program runs from an XP machine on the desktop or over the network the program works for any user. When it runs from Win 7 on the desktop it works for everyone, but when it runs from Win 7 over the network it fails for users with fewer permissions. Below is the code. It fails on the last line "Dim searchResult As SearchResult = directorySearcher.FindOne"
Dim adpath As String = "LDAP://OU=orgOU,DC=ad,DC=orgDC,DC=edu"
Dim directoryEntry As New DirectoryEntry(adpath)
directoryEntry.AuthenticationType = AuthenticationTypes.Secure
Dim directorySearcher As New DirectorySearcher(directoryEntry)
directorySearcher.Filter = getFilter(samAccountName)
directorySearcher.SearchScope = SearchScope.Subtree
Dim searchResult As SearchResult = directorySearcher.FindOne
Can anyone tell me what is missing in the network permissions?
回答1:
You appear to be using serverless binding, try setting:
AuthenticationType = AuthenticationTypes.Secure | AuthenticationTypes.ReadonlyServer
From the MSDN documentation on AuthenticationTypes.ReadOnlyServer
:
For Active Directory Domain Services, this flag indicates that a writable server is not required for a serverless binding.
Also you should be disposing your disposable objects, preferably with the Using statement. Something like:
Using directoryEntry = New DirectoryEntry...
Using directorySearcher = new DirectorySearcher(...
来源:https://stackoverflow.com/questions/7339977/directorysearcher-not-working-for-windows-7-64-bit-or-32-bit-over-network