DirectoryEntry failed to bind to AD LDS

0

I have an AD LDS instance in one server, this server is also in AD test.local. A AD user test\administrator was added to the AD LDS Administrators Role. I have configured the AD LDS instance, make it can be authenticated by the AD user, and I test it with LDP and ADSI Edit, it can be bind with user test\administrator in the two MS tools. Bind when I try to do this with code, keep get bind exception.

var directory = new DirectoryEntry("ldap://server:50000/CN=instance,CD=test,DC=local");
directory.Username = "test\\administrator";
directory.Password = "abc123,./";
//call directory.NativeObject to execute bind action
var nativeObj = directory.NativeObject;

Following is exception:

System.Runtime.InteropServices.COMException was unhandled
  ErrorCode=-2147463168
  HResult=-2147463168
  Message=Unknown error (0x80005000)
  Source=System.DirectoryServices
  StackTrace:
       at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
       at System.DirectoryServices.DirectoryEntry.Bind()
       at System.DirectoryServices.DirectoryEntry.get_NativeObject()
       at ConsoleApplication1.Program.Test() in C:\Users\Administrator\Documents\Visual Studio 2015\Projects\WindowsFormsApplication1\ConsoleApplication1\Program.cs:line 42
       at ConsoleApplication1.Program.Main(String[] args) in C:\Users\Administrator\Documents\Visual Studio 2015\Projects\WindowsFormsApplication1\ConsoleApplication1\Program.cs:line 33
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 

After I do more investigation, I found the exception was throwed by a com invoke, the detail exception is in following:

       ErrorCode=-2147023570
       ExtendedError=-2146893044
       ExtendedErrorMessage=8009030C: LdapErr: DSID-0C09042F, comment: AcceptSecurityContext error, data 2030, v2580
       HResult=-2147023570
       Message=The user name or password is incorrect.

This have cost me too much time, but I still have no idea how to fix it? Or DirectoryEntry cannot worked on AD LDS?

.net
active-directory
adlds
asked on Stack Overflow May 16, 2019 by YonF

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0