Question

Je suis en train de se lier à un serveur Active Directory en C #, mais sur place il me semble avoir des problèmes non reproductibles dans l'environnement de test.

Je reçois une exception

System.Runtime.InteropServices.COMException (0x8007203A): The server is not operational.
   at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
   at System.DirectoryServices.DirectoryEntry.Bind()
   at System.DirectoryServices.DirectoryEntry.RefreshCache()
   at System.DirectoryServices.DirectoryEntry.FillCache(String propertyName)
   at System.DirectoryServices.DirectoryEntry.get_NativeGuid()  

les regards de code comme celui-ci

// domainStr = "LDAP://domainname/rootDSE
using (var de = new DirectoryEntry(domainStr, Username, Password))
{
    var guid = de.NativeGuid;
}

si je tente de relier le plus il fonctionne très bien à la place du contrôleur de domaine (ou domainStr = "LDAP://domainController/rootDSE" domainStr = "LDAP://domainController.DomainName" qualifié).

J'ai essayé

var d = Domain.GetDomain(new DirectoryContext(
            DirectoryContextType.Domain,
            domainStr,
            Username,
            Password));

mais je reçois exactement la même exception lorsque vous faites cela.

Je me demande si je fais quelque chose de mal, peut-être une autre URL LDAP fonctionnerait mieux ou si c'est un problème commun que je vais avoir (même si les recherches Google mettent en place ce problème, je ne l'ai pas trouvé une solution fonctionne pour moi)

En outre, il pourrait être intéressant de souligner que le serveur le logiciel est en cours d'exécution n'est pas dans un Active Directory et j'ai une liste d'annonces que je vous connecter à (d'où le nom d'utilisateur et mot de passe lors de la connexion)

Était-ce utile?

La solution

It's because the DNS server doesn't have an A record for the domain. The DNS server doesn't know what IP address to resolve to when you pass a domain name to it. Normally, you don't have this problem because by default the MS Windows built-in DNS server would add this A record for you. However, in large enterprise, very often, they are not using MS Windows built-in DNS server. In many cases, people just don't bother to add an A record to the domain name.

If possible, you can ask your customer to add an A record to the DNS server. Alternatively, ask you customer to fix up the c:\windows\system32\drivers\etc\hosts file. Then, add an A record there. You can just make it point to any one of the domain controller. However, this approach does not scale because user in different sites are all going to resolve the domain name to the same IP address. To some remote site users, they may experience slowness issue.

If you also want to solve the scalability issue, you can consider to impersonate the user instead of passing the username password into the DirectoryEntry. Once you impersonate a domain user, you can use server-less binding like this LDAP://RootDSE.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top