DirectorySearcher not working for Windows 7 64 bit or 32 bit over network

狂风中的少年 提交于 2020-01-15 12:02:38

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!