{"action":"created","comment":{"url":"https://api.github.com/repos/sdelements/sdetools/pulls/comments/86181167","pull_request_review_id":6851214,"id":86181167,"diff_hunk":"@@ -0,0 +1,835 @@\n+from collections import defaultdict\n+\n+import ldap\n+import re\n+\n+from ldap.controls import SimplePagedResultsControl\n+from ldap.filter import escape_filter_chars\n+\n+from sdetools.sdelib import log_mgr\n+from sdetools.sdelib import sdeapi\n+from sdetools.sdelib.commons import Error\n+from sdetools.sdelib.restclient import APIError\n+\n+\n+logger = log_mgr.mods.add_mod(__name__)\n+\n+\n+class LDAPConnectorError(Error):\n+    pass\n+\n+\n+DEFAULT_SCHEMA = {\n+    'ldap': {\n+        'first_name': 'gn',\n+        'last_name': 'sn',\n+        'full_name': 'cn',\n+        'email': 'mail'\n+    },\n+    'ad': {\n+        'first_name': 'givenName',\n+        'last_name': 'sn',\n+        'full_name': 'cn',\n+        'email': 'mail'\n+    }\n+}\n+\n+# Enums\n+UPDATED = 1\n+DEACTIVATED = 2\n+\n+\n+class LDAPHelper(object):\n+    \"\"\"\n+    Helper class for all LDAP related functions.\n+    \"\"\"\n+\n+    # Organizational Unit Regex\n+    ou_regex = re.compile('(ou=\\w*)', re.I)\n+\n+    def __init__(self, config):\n+        self.config = config\n+        self._add_config_options()\n+\n+    def _add_config_options(self):\n+        \"\"\"Adds LDAP specific config options to the config file\"\"\"\n+        self.config.opts.add(\"ldap_server\",\n+                             \"endpoint of LDAP server\")\n+        self.config.opts.add(\"ldap_method\",\n+                             \"protocol of LDAP connection\",\n+                             default=\"LDAP\")","path":"sdetools/modules/sync_ldap/ldap_module.py","position":60,"original_position":60,"commit_id":"dba80fc979e5b3b2fc45b9c5a8f52d51dd606dae","original_commit_id":"dba80fc979e5b3b2fc45b9c5a8f52d51dd606dae","user":{"login":"geoffwhittington","id":1770544,"avatar_url":"https://avatars.githubusercontent.com/u/1770544?v=3","gravatar_id":"","url":"https://api.github.com/users/geoffwhittington","html_url":"https://github.com/geoffwhittington","followers_url":"https://api.github.com/users/geoffwhittington/followers","following_url":"https://api.github.com/users/geoffwhittington/following{/other_user}","gists_url":"https://api.github.com/users/geoffwhittington/gists{/gist_id}","starred_url":"https://api.github.com/users/geoffwhittington/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/geoffwhittington/subscriptions","organizations_url":"https://api.github.com/users/geoffwhittington/orgs","repos_url":"https://api.github.com/users/geoffwhittington/repos","events_url":"https://api.github.com/users/geoffwhittington/events{/privacy}","received_events_url":"https://api.github.com/users/geoffwhittington/received_events","type":"User","site_admin":false},"body":"I think we should default to `ldaps` here?","created_at":"2016-11-02T16:17:11Z","updated_at":"2016-11-02T16:17:12Z","html_url":"https://github.com/sdelements/sdetools/pull/326#discussion_r86181167","pull_request_url":"https://api.github.com/repos/sdelements/sdetools/pulls/326","_links":{"self":{"href":"https://api.github.com/repos/sdelements/sdetools/pulls/comments/86181167"},"html":{"href":"https://github.com/sdelements/sdetools/pull/326#discussion_r86181167"},"pull_request":{"href":"https://api.github.com/repos/sdelements/sdetools/pulls/326"}}},"pull_request":{"url":"https://api.github.com/repos/sdelements/sdetools/pulls/326","id":56248043,"html_url":"https://github.com/sdelements/sdetools/pull/326","diff_url":"https://github.com/sdelements/sdetools/pull/326.diff","patch_url":"https://github.com/sdelements/sdetools/pull/326.patch","issue_url":"https://api.github.com/repos/sdelements/sdetools/issues/326","number":326,"state":"open","locked":false,"title":"LDAP Sync","user":{"login":"geoffwhittington","id":1770544,"avatar_url":"https://avatars.githubusercontent.com/u/1770544?v=3","gravatar_id":"","url":"https://api.github.com/users/geoffwhittington","html_url":"https://github.com/geoffwhittington","followers_url":"https://api.github.com/users/geoffwhittington/followers","following_url":"https://api.github.com/users/geoffwhittington/following{/other_user}","gists_url":"https://api.github.com/users/geoffwhittington/gists{/gist_id}","starred_url":"https://api.github.com/users/geoffwhittington/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/geoffwhittington/subscriptions","organizations_url":"https://api.github.com/users/geoffwhittington/orgs","repos_url":"https://api.github.com/users/geoffwhittington/repos","events_url":"https://api.github.com/users/geoffwhittington/events{/privacy}","received_events_url":"https://api.github.com/users/geoffwhittington/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-01-16T07:17:58Z","updated_at":"2016-11-02T16:17:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"421fba1a64b1c49f94f24bab5f6f66c0500b9728","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/sdelements/sdetools/pulls/326/commits","review_comments_url":"https://api.github.com/repos/sdelements/sdetools/pulls/326/comments","review_comment_url":"https://api.github.com/repos/sdelements/sdetools/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sdelements/sdetools/issues/326/comments","statuses_url":"https://api.github.com/repos/sdelements/sdetools/statuses/dba80fc979e5b3b2fc45b9c5a8f52d51dd606dae","head":{"label":"sdelements:feature/sync_ldap","ref":"feature/sync_ldap","sha":"dba80fc979e5b3b2fc45b9c5a8f52d51dd606dae","user":{"login":"sdelements","id":739346,"avatar_url":"https://avatars.githubusercontent.com/u/739346?v=3","gravatar_id":"","url":"https://api.github.com/users/sdelements","html_url":"https://github.com/sdelements","followers_url":"https://api.github.com/users/sdelements/followers","following_url":"https://api.github.com/users/sdelements/following{/other_user}","gists_url":"https://api.github.com/users/sdelements/gists{/gist_id}","starred_url":"https://api.github.com/users/sdelements/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sdelements/subscriptions","organizations_url":"https://api.github.com/users/sdelements/orgs","repos_url":"https://api.github.com/users/sdelements/repos","events_url":"https://api.github.com/users/sdelements/events{/privacy}","received_events_url":"https://api.github.com/users/sdelements/received_events","type":"Organization","site_admin":false},"repo":{"id":4272561,"name":"sdetools","full_name":"sdelements/sdetools","owner":{"login":"sdelements","id":739346,"avatar_url":"https://avatars.githubusercontent.com/u/739346?v=3","gravatar_id":"","url":"https://api.github.com/users/sdelements","html_url":"https://github.com/sdelements","followers_url":"https://api.github.com/users/sdelements/followers","following_url":"https://api.github.com/users/sdelements/following{/other_user}","gists_url":"https://api.github.com/users/sdelements/gists{/gist_id}","starred_url":"https://api.github.com/users/sdelements/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sdelements/subscriptions","organizations_url":"https://api.github.com/users/sdelements/orgs","repos_url":"https://api.github.com/users/sdelements/repos","events_url":"https://api.github.com/users/sdelements/events{/privacy}","received_events_url":"https://api.github.com/users/sdelements/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sdelements/sdetools","description":"SD Element Tools: A collection of SD Elements integration tools built around SD Elements API.","fork":false,"url":"https://api.github.com/repos/sdelements/sdetools","forks_url":"https://api.github.com/repos/sdelements/sdetools/forks","keys_url":"https://api.github.com/repos/sdelements/sdetools/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sdelements/sdetools/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sdelements/sdetools/teams","hooks_url":"https://api.github.com/repos/sdelements/sdetools/hooks","issue_events_url":"https://api.github.com/repos/sdelements/sdetools/issues/events{/number}","events_url":"https://api.github.com/repos/sdelements/sdetools/events","assignees_url":"https://api.github.com/repos/sdelements/sdetools/assignees{/user}","branches_url":"https://api.github.com/repos/sdelements/sdetools/branches{/branch}","tags_url":"https://api.github.com/repos/sdelements/sdetools/tags","blobs_url":"https://api.github.com/repos/sdelements/sdetools/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sdelements/sdetools/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sdelements/sdetools/git/refs{/sha}","trees_url":"https://api.github.com/repos/sdelements/sdetools/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sdelements/sdetools/statuses/{sha}","languages_url":"https://api.github.com/repos/sdelements/sdetools/languages","stargazers_url":"https://api.github.com/repos/sdelements/sdetools/stargazers","contributors_url":"https://api.github.com/repos/sdelements/sdetools/contributors","subscribers_url":"https://api.github.com/repos/sdelements/sdetools/subscribers","subscription_url":"https://api.github.com/repos/sdelements/sdetools/subscription","commits_url":"https://api.github.com/repos/sdelements/sdetools/commits{/sha}","git_commits_url":"https://api.github.com/repos/sdelements/sdetools/git/commits{/sha}","comments_url":"https://api.github.com/repos/sdelements/sdetools/comments{/number}","issue_comment_url":"https://api.github.com/repos/sdelements/sdetools/issues/comments{/number}","contents_url":"https://api.github.com/repos/sdelements/sdetools/contents/{+path}","compare_url":"https://api.github.com/repos/sdelements/sdetools/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sdelements/sdetools/merges","archive_url":"https://api.github.com/repos/sdelements/sdetools/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sdelements/sdetools/downloads","issues_url":"https://api.github.com/repos/sdelements/sdetools/issues{/number}","pulls_url":"https://api.github.com/repos/sdelements/sdetools/pulls{/number}","milestones_url":"https://api.github.com/repos/sdelements/sdetools/milestones{/number}","notifications_url":"https://api.github.com/repos/sdelements/sdetools/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sdelements/sdetools/labels{/name}","releases_url":"https://api.github.com/repos/sdelements/sdetools/releases{/id}","deployments_url":"https://api.github.com/repos/sdelements/sdetools/deployments","created_at":"2012-05-09T14:33:34Z","updated_at":"2016-10-25T03:10:38Z","pushed_at":"2016-11-01T22:04:29Z","git_url":"git://github.com/sdelements/sdetools.git","ssh_url":"git@github.com:sdelements/sdetools.git","clone_url":"https://github.com/sdelements/sdetools.git","svn_url":"https://github.com/sdelements/sdetools","homepage":"","size":16016,"stargazers_count":14,"watchers_count":14,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":16,"forks":4,"open_issues":16,"watchers":14,"default_branch":"develop"}},"base":{"label":"sdelements:develop","ref":"develop","sha":"b2bae746a33fe8a329378f697441570bdea35fed","user":{"login":"sdelements","id":739346,"avatar_url":"https://avatars.githubusercontent.com/u/739346?v=3","gravatar_id":"","url":"https://api.github.com/users/sdelements","html_url":"https://github.com/sdelements","followers_url":"https://api.github.com/users/sdelements/followers","following_url":"https://api.github.com/users/sdelements/following{/other_user}","gists_url":"https://api.github.com/users/sdelements/gists{/gist_id}","starred_url":"https://api.github.com/users/sdelements/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sdelements/subscriptions","organizations_url":"https://api.github.com/users/sdelements/orgs","repos_url":"https://api.github.com/users/sdelements/repos","events_url":"https://api.github.com/users/sdelements/events{/privacy}","received_events_url":"https://api.github.com/users/sdelements/received_events","type":"Organization","site_admin":false},"repo":{"id":4272561,"name":"sdetools","full_name":"sdelements/sdetools","owner":{"login":"sdelements","id":739346,"avatar_url":"https://avatars.githubusercontent.com/u/739346?v=3","gravatar_id":"","url":"https://api.github.com/users/sdelements","html_url":"https://github.com/sdelements","followers_url":"https://api.github.com/users/sdelements/followers","following_url":"https://api.github.com/users/sdelements/following{/other_user}","gists_url":"https://api.github.com/users/sdelements/gists{/gist_id}","starred_url":"https://api.github.com/users/sdelements/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sdelements/subscriptions","organizations_url":"https://api.github.com/users/sdelements/orgs","repos_url":"https://api.github.com/users/sdelements/repos","events_url":"https://api.github.com/users/sdelements/events{/privacy}","received_events_url":"https://api.github.com/users/sdelements/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sdelements/sdetools","description":"SD Element Tools: A collection of SD Elements integration tools built around SD Elements API.","fork":false,"url":"https://api.github.com/repos/sdelements/sdetools","forks_url":"https://api.github.com/repos/sdelements/sdetools/forks","keys_url":"https://api.github.com/repos/sdelements/sdetools/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sdelements/sdetools/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sdelements/sdetools/teams","hooks_url":"https://api.github.com/repos/sdelements/sdetools/hooks","issue_events_url":"https://api.github.com/repos/sdelements/sdetools/issues/events{/number}","events_url":"https://api.github.com/repos/sdelements/sdetools/events","assignees_url":"https://api.github.com/repos/sdelements/sdetools/assignees{/user}","branches_url":"https://api.github.com/repos/sdelements/sdetools/branches{/branch}","tags_url":"https://api.github.com/repos/sdelements/sdetools/tags","blobs_url":"https://api.github.com/repos/sdelements/sdetools/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sdelements/sdetools/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sdelements/sdetools/git/refs{/sha}","trees_url":"https://api.github.com/repos/sdelements/sdetools/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sdelements/sdetools/statuses/{sha}","languages_url":"https://api.github.com/repos/sdelements/sdetools/languages","stargazers_url":"https://api.github.com/repos/sdelements/sdetools/stargazers","contributors_url":"https://api.github.com/repos/sdelements/sdetools/contributors","subscribers_url":"https://api.github.com/repos/sdelements/sdetools/subscribers","subscription_url":"https://api.github.com/repos/sdelements/sdetools/subscription","commits_url":"https://api.github.com/repos/sdelements/sdetools/commits{/sha}","git_commits_url":"https://api.github.com/repos/sdelements/sdetools/git/commits{/sha}","comments_url":"https://api.github.com/repos/sdelements/sdetools/comments{/number}","issue_comment_url":"https://api.github.com/repos/sdelements/sdetools/issues/comments{/number}","contents_url":"https://api.github.com/repos/sdelements/sdetools/contents/{+path}","compare_url":"https://api.github.com/repos/sdelements/sdetools/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sdelements/sdetools/merges","archive_url":"https://api.github.com/repos/sdelements/sdetools/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sdelements/sdetools/downloads","issues_url":"https://api.github.com/repos/sdelements/sdetools/issues{/number}","pulls_url":"https://api.github.com/repos/sdelements/sdetools/pulls{/number}","milestones_url":"https://api.github.com/repos/sdelements/sdetools/milestones{/number}","notifications_url":"https://api.github.com/repos/sdelements/sdetools/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sdelements/sdetools/labels{/name}","releases_url":"https://api.github.com/repos/sdelements/sdetools/releases{/id}","deployments_url":"https://api.github.com/repos/sdelements/sdetools/deployments","created_at":"2012-05-09T14:33:34Z","updated_at":"2016-10-25T03:10:38Z","pushed_at":"2016-11-01T22:04:29Z","git_url":"git://github.com/sdelements/sdetools.git","ssh_url":"git@github.com:sdelements/sdetools.git","clone_url":"https://github.com/sdelements/sdetools.git","svn_url":"https://github.com/sdelements/sdetools","homepage":"","size":16016,"stargazers_count":14,"watchers_count":14,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":16,"forks":4,"open_issues":16,"watchers":14,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/sdelements/sdetools/pulls/326"},"html":{"href":"https://github.com/sdelements/sdetools/pull/326"},"issue":{"href":"https://api.github.com/repos/sdelements/sdetools/issues/326"},"comments":{"href":"https://api.github.com/repos/sdelements/sdetools/issues/326/comments"},"review_comments":{"href":"https://api.github.com/repos/sdelements/sdetools/pulls/326/comments"},"review_comment":{"href":"https://api.github.com/repos/sdelements/sdetools/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sdelements/sdetools/pulls/326/commits"},"statuses":{"href":"https://api.github.com/repos/sdelements/sdetools/statuses/dba80fc979e5b3b2fc45b9c5a8f52d51dd606dae"}}}}
{"actor":{"display_login":"geoffwhittington"}}