следующий код работает на администратора домена. Но не с правами пользователя.
using System;
using System.Collections.Generic;
using System.DirectoryServices.AccountManagement;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WinM
{
class Program
{
static void Main(string[] args)
{
PrincipalContext ctx = new PrincipalContext(ContextType.Domain);
}
}
}
Если я запускаю это как пользователь, я получаю следующую ошибку:
Unhandled Exception: System.DirectoryServices.Protocols.LdapException: The connection cannot be established.
at System.DirectoryServices.Protocols.ConnectionHandle..ctor(IntPtr value, Boolean disposeHandle)
at System.DirectoryServices.Protocols.LdapConnection.Init()
at System.DirectoryServices.Protocols.LdapConnection..ctor(LdapDirectoryIdentifier identifier, NetworkCredential credential, AuthType authType)
at System.DirectoryServices.Protocols.LdapConnection..ctor(LdapDirectoryIdentifier identifier)
at System.DirectoryServices.Protocols.LdapConnection..ctor(String server)
at System.DirectoryServices.AccountManagement.PrincipalContext.ReadServerConfig(String serverName, ServerProperties& properties)
at System.DirectoryServices.AccountManagement.PrincipalContext.DoServerVerifyAndPropRetrieval()
at System.DirectoryServices.AccountManagement.PrincipalContext..ctor(ContextType contextType, String name, String container, ContextOptions options, String userName, String password)
at System.DirectoryServices.AccountManagement.PrincipalContext..ctor(ContextType contextType)
at WinM.Program.Main(String[] args) in
Есть у кого-нибудь идея?