with the help of this code we check user exist or not on given directory.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.DirectoryServices;
using System.DirectoryServices.AccountManagement;
using System.DirectoryServices.ActiveDirectory;
using System.DirectoryServices.Protocols;
using System.Net;
namespace ADCheck
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
try
{
LdapConnection connection = new LdapConnection(txtad.Text);
NetworkCredential credential = new NetworkCredential(txtusername.Text, txtpassword.Text);
connection.Credential = credential;
connection.Bind();
Console.WriteLine("logged in");
MessageBox.Show("Successfully");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
} 