Created
February 10, 2010 21:16
-
-
Save trevmex/300850 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ActiveDirectoryUser | |
require 'restclient' | |
@authentication_site = 'https://your_server' | |
@find_site = 'http://your_server' | |
@authentication_prefix = '/your_auth_page' | |
@find_prefix = '/cgi-bin/dscl_search.sh?' | |
# Returns true if the user has the correct password, false otherwise. | |
def self.authenticate(login, password) | |
site = RestClient::Resource.new(@authentication_site, :user => login, :password => password) | |
begin | |
results = site[@authentication_prefix].get | |
auth_succeeded = true | |
rescue | |
auth_succeeded = false | |
end | |
auth_succeeded | |
end | |
# Returns the dscl information of the user if they exist, nil otherwise | |
def self.find(login) | |
begin | |
dscl_results = RestClient.get("#{@find_site}#{@find_prefix}#{login}").to_s | |
if dscl_results.blank? | |
dscl_results = nil | |
end | |
rescue | |
dscl_results = nil | |
end | |
dscl_results | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "Content-type: text/plain" | |
echo | |
dscl localhost -read /Search/Users/${1} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment