Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added LDAP.exists? and Account.exists?

  • Loading branch information...
commit 6dceaa1c40591e2391d34f7000c5fd388e454c8a 1 parent 6d2c2fa
@danopia authored
Showing with 13 additions and 0 deletions.
  1. +6 −0 account.rb
  2. +7 −0 ldap.rb
View
6 account.rb
@@ -1,3 +1,5 @@
+require 'ldap'
+
module BitServ
class Account
attr_accessor :entry
@@ -18,6 +20,10 @@ def self.load account
entry && self.new(entry)
end
+ def self.exists? account
+ LDAP.exists? LDAP.user_dn(account)
+ end
+
def initialize entry
@entry = entry
end
View
7 ldap.rb
@@ -66,6 +66,13 @@ def self.select dn, params={}
first dn, nil, params
end
+ def self.exists? dn, params={}
+ params[:scope] = Net::LDAP::SearchScope_BaseObject
+ params[:return_result] = false
+ search dn, nil, params
+ success?
+ end
+
def self.delete dn
ldap.delete :dn => dn
end
Please sign in to comment.
Something went wrong with that request. Please try again.