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. DirectoryServices - NT authentication

DirectoryServices - NT authentication

Scheduled Pinned Locked Moved C#
c++securityhelpquestion
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.
  • R Offline
    R Offline
    Ruchi Gupta
    wrote on last edited by
    #1

    I have need to authenticate users using windows authentiateion. I am using following code to do that. But problem with this is after three unsuccessful attempts, it locks user out from other applications using Directory Service, the same way when we try to login to windows machine and three consecutive wrong passwords locks the users out. Does anybody know how can I use Directory Service to make non-blocking call upon wrong password DirectoryEntry entry = new DirectoryEntry("LDAP://RootDSE"); String str = entry.Properties["defaultNamingContext"][0].ToString(); MessageBox.Show(str); DirectoryEntry domain = new DirectoryEntry("LDAP://" + str, txtLogin.Text, txtPassword.Text); try { Object native = domain.NativeObject; MessageBox.Show(txtLogin.Text + " Authenticated. Hurray!!!"); } catch(Exception ) { MessageBox.Show(txtLogin.Text + " INVALID user :-(("); } Thanks you very much, Ruchi

    U 1 Reply Last reply
    0
    • R Ruchi Gupta

      I have need to authenticate users using windows authentiateion. I am using following code to do that. But problem with this is after three unsuccessful attempts, it locks user out from other applications using Directory Service, the same way when we try to login to windows machine and three consecutive wrong passwords locks the users out. Does anybody know how can I use Directory Service to make non-blocking call upon wrong password DirectoryEntry entry = new DirectoryEntry("LDAP://RootDSE"); String str = entry.Properties["defaultNamingContext"][0].ToString(); MessageBox.Show(str); DirectoryEntry domain = new DirectoryEntry("LDAP://" + str, txtLogin.Text, txtPassword.Text); try { Object native = domain.NativeObject; MessageBox.Show(txtLogin.Text + " Authenticated. Hurray!!!"); } catch(Exception ) { MessageBox.Show(txtLogin.Text + " INVALID user :-(("); } Thanks you very much, Ruchi

      U Offline
      U Offline
      User 760775
      wrote on last edited by
      #2

      Hi Ruchi The administrator (hopefully you) of the AD can change the setting that "locks out accounts on X failed login attempts". This would solve your problem. Also, you could try the Win32 Logon user function, although I would presume that it will cause the exact same error, as your error is not an error but an AD feature. The following code will log in a user account. The token returned can be used to make ur code impersonate the specific user account, calling System.Security.Principal.WindowsIdentity.Impersonate((System.IntPtr)token), if you should ever need that. If the account is invalid, you should recieve a 0 in the token returned from the function, as well as an error in the error variable. [DllImport("advapi32.dll", SetLastError=true) ] public static extern bool LogonUser(string lpszUsername, string lpszDomain, string lpszPassword, int dwLogonType, int dwLogonProvider, outint phToken); [DllImport("C:\\Windows\\System32\\Kernel32.dll")] public static extern int GetLastError(); public static int LogonWindowsUser(string username, string domain, string password) { int token; bool isLoggedin = LogonUser(username, domain, password, 3, 0, out token); int error = GetLastError(); return token; } /Zalkina

      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