Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix active directory #267

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/active_directory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,28 @@ def create_active_directory_account(user)
return "Empty email address" if user.email.blank?

# log what is happening
logger.debug("Attempting to create active directory account for " + user.email)
Rails.logger.debug("Attempting to create active directory account for " + user.email)

# extract domain from email
domain = user.email.split('@')[1]

# Confirm domain name accuracy
if domain != GOOGLE_DOMAIN
logger.debug("Domain (" + domain + ") is not the same as the google domain (" + GOOGLE_DOMAIN)
Rails.logger.debug("Domain (" + domain + ") is not the same as the google domain (" + GOOGLE_DOMAIN)
return "Domain (" + domain + ") is not the same as the google domain (" + GOOGLE_DOMAIN + ")"
end

# Attempt to create active directory account
active_directory_service = ActiveDirectory.new
if active_directory_service.create_account(user) == "Success"
user.active_directory_account_created = Time.now()
user.active_directory_account_created_at = Time.now()
user.save
end
end


# Initialize connection to active directory
def self.initialize
def initialize
@connection = Net::LDAP.new(:host => LDAPConfig.host, :port => LDAPConfig.port)
@connection.encryption(:method => :simple_tls) unless !LDAPConfig.is_encrypted?
@connection.auth LDAPConfig.username, LDAPConfig.password unless LDAPConfig.username.nil? || LDAPConfig.password.nil?
Expand Down Expand Up @@ -108,7 +108,7 @@ def password_encode(password)
# Send active directory password reset token
def send_password_reset_token(user)
user.set_password_reset_token
self.password_reset_sent_at = Time.zone.now
user.password_reset_sent_at = Time.zone.now
user.save!
PasswordMailer.password_reset(user).deliver
end
Expand Down