LDAP-找不到网络路径 [英] Ldap - the network path was not found
问题描述
尝试在LDAP中搜索用户时遇到以下错误.
I encountered below error when trying to search users in LDAP.
该代码在本地PC上可以正常运行,并且仅在部署后在Windows服务器上发生错误.
The code runs ok at local PC and error occurs only at windows server after I deployed it.
2018-08-17 15:29:21.190 +08:00 [错误]为lsun获取全名时出错
System.DirectoryServices.DirectoryServicesCOMException(0x80070035):找不到网络路径.
2018-08-17 15:29:21.190 +08:00 [Error] Error in getting fullname for lsun
System.DirectoryServices.DirectoryServicesCOMException (0x80070035): The network path was not found.
在System.DirectoryServices.DirectoryEntry.Bind(布尔throwIfFail)处
在System.DirectoryServices.DirectoryEntry.Bind()处
在System.DirectoryServices.DirectoryEntry.get_AdsObject()
在System.DirectoryServices.PropertyValueCollection.PopulateList()处
在System.DirectoryServices.PropertyValueCollection..ctor中(DirectoryEntry条目,字符串propertyName)
在 System.DirectoryServices.PropertyCollection.get_Item(String propertyName)
在C:\ Code \ Project \ branches \ test \ src \ DotNet \ Company.Project.Common \ Utility \ LDAPUtility.cs:line 344
中的Company.Project.Common.Utility.LDAPUtility.QueryLDAPUserFullName(String userId)在C:\ Code \ Project \ branches \ test \ src \ DotNet \ Company.Project.Common \ Utility \ LDAPUtility.cs:line 239
at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
at System.DirectoryServices.DirectoryEntry.Bind()
at System.DirectoryServices.DirectoryEntry.get_AdsObject()
at System.DirectoryServices.PropertyValueCollection.PopulateList()
at System.DirectoryServices.PropertyValueCollection..ctor(DirectoryEntry entry, String propertyName)
at System.DirectoryServices.PropertyCollection.get_Item(String propertyName)
at Company.Project.Common.Utility.LDAPUtility.QueryLDAPUserFullName(String userId) in C:\Code\Project\branches\test\src\DotNet\Company.Project.Common\Utility\LDAPUtility.cs:line 344
at Company.Project.Common.Utility.LDAPUtility.GetUserFullName(String userId) in C:\Code\Project\branches\test\src\DotNet\Company.Project.Common\Utility\LDAPUtility.cs:line 239
这是Windows服务应用程序,这是引发错误的代码:
This is a Windows service application and this is the code throwing the error:
private static string QueryLDAPUserFullName(string userId)
{
string fullName = "";
DirectoryEntry objDirEnt = new DirectoryEntry(ConstPrivileges.ADSPROVIDER + "://" + ConstPrivileges.DOMAIN + "/" + userId);
if (objDirEnt.Children != null)
fullName = objDirEnt.Properties["FullName"].Value.ToString();//Line 344
return fullName;
}
推荐答案
我通过将Windows Service登录从本地服务"更改为网络服务"来解决了此问题.在我看来,本地服务没有特权连接到LDAP.
I fixed this issue by changing the windows service logon from 'Local Service' to 'Network Service'. It seems to me that Local Service does not have privilege to connect to LDAP.
这篇关于LDAP-找不到网络路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!