diff --git a/Package.swift b/Package.swift index ae9f039..07f042d 100644 --- a/Package.swift +++ b/Package.swift @@ -3,7 +3,7 @@ import PackageDescription let package = Package( name: "PerfectLDAP", dependencies:[ - .Package(url: "https://github.com/RockfordWei/Perfect-ICONV.git", majorVersion: 1), + .Package(url: "https://github.com/PerfectSideRepos/Perfect-ICONV.git", majorVersion: 1), .Package(url:"https://github.com/PerfectlySoft/Perfect-Thread.git", majorVersion: 2), .Package(url:"https://github.com/PerfectlySoft/Perfect-OpenLDAP.git", majorVersion: 1) ] diff --git a/Sources/PerfectLDAP.swift b/Sources/PerfectLDAP.swift index 8c05e8a..1f3fb39 100644 --- a/Sources/PerfectLDAP.swift +++ b/Sources/PerfectLDAP.swift @@ -158,6 +158,22 @@ public class LDAP { }//end str }//end string + public var _supportedControls = [String]() + + /// load session control OIDs from server + /// - throws: + /// Exception with messages. + public func checkServerSideControls() throws { + guard let r = try self.search() else { + throw Exception.message("load controls failed") + }//end guard + guard let root = r.dictionary[""] else { + throw Exception.message("control has no expected key") + }//end guard + _supportedControls = root["supportedControl"] as? [String] ?? [] + + }//end func + /// constructor of LDAP. could be a simple LDAP() to local server or LDAP(url) with / without logon options. /// if login parameters were input, the process would block until finished. /// so it is strongly recommanded that call LDAP() without login option and call ldap.login() {} in async mode diff --git a/Tests/PerfectLDAPTests/PerfectLDAPTests.swift b/Tests/PerfectLDAPTests/PerfectLDAPTests.swift index 0fd171c..d94177e 100644 --- a/Tests/PerfectLDAPTests/PerfectLDAPTests.swift +++ b/Tests/PerfectLDAPTests/PerfectLDAPTests.swift @@ -46,6 +46,9 @@ class PerfectLDAPTests: XCTestCase { let succ = ldap.login(username: testUSR, password: testPWD) XCTAssertTrue(succ) + + try ldap.checkServerSideControls() + print(ldap._supportedControls) }catch(let err) { XCTFail("testLoginSync error: \(err)") }