Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. How to bind data to a dropdown using Active Directory

How to bind data to a dropdown using Active Directory

Scheduled Pinned Locked Moved ASP.NET
windows-adminhelptutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    babutkchn
    wrote on last edited by
    #1

    Hi, I have to retrieve data from Active directory and bind that to a dropdown list control.Can any one help me to do the function. Thanks in advance. Babu

    M 1 Reply Last reply
    0
    • B babutkchn

      Hi, I have to retrieve data from Active directory and bind that to a dropdown list control.Can any one help me to do the function. Thanks in advance. Babu

      M Offline
      M Offline
      MIHAI_MTZ
      wrote on last edited by
      #2

      It's not binding but here it goes: You should replace these lines with the proper values entry.Path = "GC://****"; entry.Username = txtUN.Text; entry.Password = txtPW.Text; DirectoryEntry entry = new DirectoryEntry(); entry.Path = "GC://****"; entry.Username = txtUN.Text; entry.Password = txtPW.Text; DirectorySearcher ds = new DirectorySearcher(entry); ds.Filter = txtQuery.Text; ds.CacheResults = false; ds.SearchScope = SearchScope.Subtree; foreach (string s in cols) ds.PropertiesToLoad.Add(s); src = ds.FindAll(); cbResults.Items.Clear(); for (int i = 0; i < src.Count; i++) { if (src[i].GetDirectoryEntry().Properties["mail"].Value != null) cbResults.Items.Add(src[i].GetDirectoryEntry().Properties["mail"].Value); else cbResults.Items.Add(i); } private string[] cols = { "displayName", "givenName", "sn", "ou", "employeeType", "mail", "telephoneNumber", "samAccountNumber", "whenCreated", "whenChanged", "objectGUID", "c", "objectCategory", "anr", "otherTelephone", "cn", "badPwdCount", "lockoutTime", "pwdLastSet", "lastLogon", "mobile", "Profile", "LastLogin", "MaxStorage", "PasswordAge", "Description", };

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups