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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. user validation throug active directory (LDAP)

user validation throug active directory (LDAP)

Scheduled Pinned Locked Moved ASP.NET
questioncsharpc++asp-netdatabase
3 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.
  • M Offline
    M Offline
    machocr
    wrote on last edited by
    #1

    Hi, I need to validate users throug active directory in asp.net 2.0. The users will be on diferents locations and dommains. The users aer part of differents companies with differents dommains, so for a single user I need to search the company at database and load the company settings to be able to do the authentication by active directory. Is that possible? Which active directory settings do I need to store for each company? How can I do that validation? I have the following snippept: 1. public bool AuthenticateUser(string domain, string username, string 2. password) 3. { 4. string domainAndUsername = domain + @"\" + username; 5. DirectoryEntry entry = new DirectoryEntry( LDAPPATH, 6. domainAndUsername, 7. password); 8. try 9. { 10. // Bind to the native AdsObject to force authentication. 11. Object obj = entry.NativeObject; 12. DirectorySearcher search = new DirectorySearcher(entry); 13. search.Filter = "(SAMAccountName=" + username + ")"; 14. search.PropertiesToLoad.Add("cn"); 15. SearchResult result = search.FindOne(); 16. if(null == result) 17. { 18. return false; 19. } 20. // Update the new path to the user in the directory 21. LDAPPATH = result.Path; 22. } 23. catch (Exception ex) 24. { 25. throw new Exception("Error authenticating user.” + ex.Message); 26. } 27. return true; 28. } Is the code I need? can you explain me how to contruct LDAPPATH? Thank you I'm very newie with AD.:confused:

    La realidad no es más que impulsos eléctricos del cerebro - Morpheus

    M 1 Reply Last reply
    0
    • M machocr

      Hi, I need to validate users throug active directory in asp.net 2.0. The users will be on diferents locations and dommains. The users aer part of differents companies with differents dommains, so for a single user I need to search the company at database and load the company settings to be able to do the authentication by active directory. Is that possible? Which active directory settings do I need to store for each company? How can I do that validation? I have the following snippept: 1. public bool AuthenticateUser(string domain, string username, string 2. password) 3. { 4. string domainAndUsername = domain + @"\" + username; 5. DirectoryEntry entry = new DirectoryEntry( LDAPPATH, 6. domainAndUsername, 7. password); 8. try 9. { 10. // Bind to the native AdsObject to force authentication. 11. Object obj = entry.NativeObject; 12. DirectorySearcher search = new DirectorySearcher(entry); 13. search.Filter = "(SAMAccountName=" + username + ")"; 14. search.PropertiesToLoad.Add("cn"); 15. SearchResult result = search.FindOne(); 16. if(null == result) 17. { 18. return false; 19. } 20. // Update the new path to the user in the directory 21. LDAPPATH = result.Path; 22. } 23. catch (Exception ex) 24. { 25. throw new Exception("Error authenticating user.” + ex.Message); 26. } 27. return true; 28. } Is the code I need? can you explain me how to contruct LDAPPATH? Thank you I'm very newie with AD.:confused:

      La realidad no es más que impulsos eléctricos del cerebro - Morpheus

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

      The How-to documents below may give you some ideas: http://msdn.microsoft.com/library/en-us/dnpag2/html/PAGHT000026.asp[^] http://msdn.microsoft.com/library/en-us/dnpag2/html/PAGHT000021.asp[^]

      M 1 Reply Last reply
      0
      • M minhpc_bk

        The How-to documents below may give you some ideas: http://msdn.microsoft.com/library/en-us/dnpag2/html/PAGHT000026.asp[^] http://msdn.microsoft.com/library/en-us/dnpag2/html/PAGHT000021.asp[^]

        M Offline
        M Offline
        machocr
        wrote on last edited by
        #3

        Thank you very much. The links are very very useful. :omg: :wtf:

        La realidad no es más que impulsos eléctricos del cerebro - Morpheus

        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