Fehler 0x80005000 und VerzeichnisservicesC#

Ein Treffpunkt für C#-Programmierer
Guest
 Fehler 0x80005000 und Verzeichnisservices

Post by Guest »

Ich versuche, eine einfache LDAP -Abfrage mit Verzeichnisdiensten in .NET auszuführen. < /p>

DirectoryEntry directoryEntry = new DirectoryEntry("LDAP://someserver.contoso.com/DC=contoso,DC=com");
directoryEntry.AuthenticationType = AuthenticationTypes.Secure;

DirectorySearcher directorySearcher = new DirectorySearcher(directoryEntry);

directorySearcher.Filter = string.Format("(&(objectClass=user)(objectCategory=user) (sAMAccountName={0}))", username);

var result = directorySearcher.FindOne();
var resultDirectoryEntry = result.GetDirectoryEntry();

return resultDirectoryEntry.Properties["msRTCSIP-PrimaryUserAddress"].Value.ToString();
< /code>

und ich erhalte die folgende Ausnahme: < /p>

System.Runtime.InteropServices.COMException (0x80005000): Unknown error (0x80005000)
at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
at System.DirectoryServices.DirectoryEntry.Bind()
at System.DirectoryServices.DirectoryEntry.get_AdsObject()
at System.DirectoryServices.DirectorySearcher.FindAll(Boolean findMoreThanOne)
at System.DirectoryServices.DirectorySearcher.FindOne()
< /code>

Als Snippet in einer Konsolen -App funktioniert dies. Aber wenn ich es als Teil eines WCF -Dienstes ausführe (unter denselben Anmeldeinformationen ausführen), wirft es die obige Ausnahme aus. < /P>

Vorschläge? >
Danke < /p>

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post