Server_Name :servername.cloudapp.net
IP_Address : x.x.x.x
Protocol_Type : Recursive LDAP
LDAP_Port : 389
User_OU : xxx.xxx.world.local/city/city Projects/city Worksheet/CityUsers
Domain : xxx.xxx.world.local
Service_Account : city\serviceaccountname
Svc_Credentials : serviceaccountpwd
Using the above details i tried to connect to active directory service account using ldap, but i am not able to connectand authenticate user credentials entered.
应用程序包含一个登录屏幕,用户可以在其中输入他/她的用户名和密码,提供的用户名和密码应在活动目录中进行身份验证 .
请帮帮我 make connection to the active directory service account and authenticate the user credentials entered.
请在下面找到用于身份验证的代码:
public void Autherize(User user)
{
DirectoryEntry de = new DirectoryEntry("LDAP://IP_Address:LDAP Port/OU=CityUsers,OU=city Worksheet,OU=city Projects,OU=city,DC=xxx,DC=xxx,DC=world,DC=local", "city\serviceaccountname", "serviceaccountpwd");
DirectorySearcher ds = new DirectorySearcher(de);
try
{
SearchResult result = ds.FindOne();
if (result != null)
{
foreach (string propName in result.Properties.PropertyNames)
{
foreach (object myCollection in result.Properties[propName])
{
Debug.WriteLine(propName + " : " + myCollection.ToString());
}
}
}
else
Debug.WriteLine("Error: Not found");
}
catch (Exception f)
{
Debug.WriteLine("Error:" + f.Message);
}
}