SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist
    Join Date
    Feb 2006
    Location
    Worcs. UK
    Posts
    404
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Getting user information from Active Directory

    I want to be able to look up user information (e-mail addresses and telephone numbers for example) in Active Directory, from within my Rails application. I've been banging my head against a brick wall for a couple of days trying to get the Ruby LDAP tools working on a Windows system without success. Then I thought, why don't I just do it the way I would do it in VBScript. Three lines of ruby code later and I'm outputing the list of objects in my root "people" OU container.
    Code:
    require "win32ole"
    
    # Creates a new LDAP object which is the people OU.
    myLDAP = WIN32OLE.connect("LDAP://server.domain.com/ou=people,dc=domain,dc=com")
    
    #Loop through the sub objects outputing their name
    myLDAP.each {|child| puts child.name}
    I only want read access to the data so I'm not concerned if I can't write to AD this way.

    Anyone know if there are any issues with this way of accessing AD?
    Do I need to close the myLDAP object when I've grabbed the information I want, and if so what is the best way of doing it?

  2. #2
    SitePoint Guru
    Join Date
    Aug 2005
    Posts
    986
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think it will be closed automatically, but if it doesn't maybe use:

    Code:
    myLDAP.Quit()
    Just like they're doing here:

    http://www.rubycentral.com/book/win32.html


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •