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. General Programming
  3. C#
  4. active directory users

active directory users

Scheduled Pinned Locked Moved C#
windows-admin
4 Posts 3 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.
  • C Offline
    C Offline
    caiena
    wrote on last edited by
    #1

    can someone put a code snip here that i can use to determin if a adusers is disabled

    L 1 Reply Last reply
    0
    • C caiena

      can someone put a code snip here that i can use to determin if a adusers is disabled

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Sorry, I don't quite understand what it is you want, but I found this article[^] here on codeproject which seems to deal a lot with the active directory, should have something about what you are trying to get information on. If not, try any of the following hits: 1[^] 2[^] Sorry I couldn't be of more help. Edit: Some more links on codeproject about querying / interacting with the AD; First Link - deals with querying the AD[^] Second Link - deals with authentication[^] Third Link - More querying AD[^] Let me know how it goes.

      Check out the CodeProject forum Guidelines[^] The original soapbox 1.0 is back![^]

      modified on Tuesday, June 23, 2009 5:09 PM

      C 1 Reply Last reply
      0
      • L Lost User

        Sorry, I don't quite understand what it is you want, but I found this article[^] here on codeproject which seems to deal a lot with the active directory, should have something about what you are trying to get information on. If not, try any of the following hits: 1[^] 2[^] Sorry I couldn't be of more help. Edit: Some more links on codeproject about querying / interacting with the AD; First Link - deals with querying the AD[^] Second Link - deals with authentication[^] Third Link - More querying AD[^] Let me know how it goes.

        Check out the CodeProject forum Guidelines[^] The original soapbox 1.0 is back![^]

        modified on Tuesday, June 23, 2009 5:09 PM

        C Offline
        C Offline
        caiena
        wrote on last edited by
        #3

        i tried this method to see if i could figure out if the user was disabled but i get and error i just wanted to see if i would get a 0x1 if the user account is not disbled and a 0x2 if it was public void Disable(string userDn) { try { DirectoryEntry user = new DirectoryEntry(userDn); int val = (int)user.Properties["userAccountControl"].Value; \\ get the error on the above line user.Properties["userAccountControl"].Value = val | 0x2; //ADS_UF_ACCOUNTDISABLE; } catch (System.DirectoryServices.DirectoryServicesCOMException E) { //DoSomethingWith --> E.Message.ToString(); } }

        R 1 Reply Last reply
        0
        • C caiena

          i tried this method to see if i could figure out if the user was disabled but i get and error i just wanted to see if i would get a 0x1 if the user account is not disbled and a 0x2 if it was public void Disable(string userDn) { try { DirectoryEntry user = new DirectoryEntry(userDn); int val = (int)user.Properties["userAccountControl"].Value; \\ get the error on the above line user.Properties["userAccountControl"].Value = val | 0x2; //ADS_UF_ACCOUNTDISABLE; } catch (System.DirectoryServices.DirectoryServicesCOMException E) { //DoSomethingWith --> E.Message.ToString(); } }

          R Offline
          R Offline
          rolandm6610
          wrote on last edited by
          #4

          This is what I use passing in the DirectoryEntry object as a paramater.

          public static bool CheckAccountDisabled(DirectoryEntry de)
          {
          int ACCOUNTDISABLE = 0x0002;
          int flags = (int)de.Properties["userAccountControl"].Value;
          if (((flags & ACCOUNTDISABLE) == ACCOUNTDISABLE))
          {
          return true;
          }
          return false;
          }

          modified on Thursday, June 25, 2009 6:02 PM

          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