Simple Bind: Use ASCII : Bind « Directory Services « C# / CSharp Tutorial






using System;
using System.Runtime.InteropServices;
using LDAP32;

unsafe class MainClass
{
  private static uint LDAP_PORT = 389;
  [STAThread]
  static void Main(string[] args)
  {
    LDAP32.LDAP* pLdap = null;
    sbyte* pServer = (sbyte*)Marshal.StringToCoTaskMemAnsi("dsaddom.nttest.microsoft.com");
    sbyte* pName = (sbyte*)Marshal.StringToCoTaskMemAnsi("CN=Greg MacBeth,CN=Users,DC=dsaddom,DC=nttest,DC=MICROSOFT,DC=COM");
    sbyte* pPassword = (sbyte*)Marshal.StringToCoTaskMemAnsi("gregmcb");
    uint Result = 0;

        pLdap = Wldap32.ldap_init(pServer, LDAP_PORT);
    if(pLdap != null)
    {
      Result = Wldap32.ldap_simple_bind_s(pLdap, pName, pPassword);
    }

    Wldap32.ldap_unbind(pLdap);

  }
}








34.1.Bind
34.1.1.Directory Binding
34.1.2.Bind Object
34.1.3.Anonymous bind
34.1.4.Binding use a specified user
34.1.5.Simple Bind: Use ASCII