{"action":"created","comment":{"url":"https://api.github.com/repos/Teradata/presto/pulls/comments/73232627","id":73232627,"diff_hunk":"@@ -13,32 +13,60 @@\n  */\n package com.facebook.presto.server.security;\n \n+import com.google.common.base.Throwables;\n+import io.airlift.log.Logger;\n+\n import javax.inject.Inject;\n+import javax.naming.NamingEnumeration;\n+import javax.naming.NamingException;\n import javax.naming.directory.DirContext;\n+import javax.naming.directory.SearchControls;\n+import javax.naming.directory.SearchResult;\n+\n+import java.util.Optional;\n \n+import static com.google.common.base.Preconditions.checkState;\n import static java.lang.String.format;\n import static java.util.Objects.requireNonNull;\n \n public class OpenLdapBinder\n         implements LdapBinder\n {\n-    private final String baseDistinguishedName;\n+    private static final Logger LOG = Logger.get(ActiveDirectoryBinder.class);\n+    private final String userObjectClass;\n+    private final Optional<String> baseDistinguishedName;\n \n     @Inject\n     public OpenLdapBinder(LdapServerConfig config)\n     {\n-        baseDistinguishedName = requireNonNull(config.getBaseDistinguishedName(), \"baseDistinguishedName is null\");\n+        userObjectClass = requireNonNull(config.getUserObjectClass(), \"userObjectClass is null\");\n+        baseDistinguishedName = Optional.ofNullable(config.getBaseDistinguishedName());\n     }\n \n     @Override\n     public String getBindDistinguishedName(String user)\n     {\n-        return format(\"uid=%s,%s\", user, baseDistinguishedName);\n+        return format(\"uid=%s,%s\", user, baseDistinguishedName.get());\n     }\n \n     @Override\n     public boolean checkForGroupMembership(String user, String groupDistinguishedName, DirContext context)\n     {\n-        throw new UnsupportedOperationException(\"Group membership based authorization not yet supported\");\n+        checkState(baseDistinguishedName.isPresent(), \"Base distinguished name (DN) for user %s is missing\", user);","path":"presto-main/src/main/java/com/facebook/presto/server/security/OpenLdapBinder.java","position":47,"original_position":47,"commit_id":"1a28be0f797ae873437a637140e80e3ddddf2e47","original_commit_id":"1a28be0f797ae873437a637140e80e3ddddf2e47","user":{"login":"anusudarsan","id":10963707,"avatar_url":"https://avatars.githubusercontent.com/u/10963707?v=3","gravatar_id":"","url":"https://api.github.com/users/anusudarsan","html_url":"https://github.com/anusudarsan","followers_url":"https://api.github.com/users/anusudarsan/followers","following_url":"https://api.github.com/users/anusudarsan/following{/other_user}","gists_url":"https://api.github.com/users/anusudarsan/gists{/gist_id}","starred_url":"https://api.github.com/users/anusudarsan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anusudarsan/subscriptions","organizations_url":"https://api.github.com/users/anusudarsan/orgs","repos_url":"https://api.github.com/users/anusudarsan/repos","events_url":"https://api.github.com/users/anusudarsan/events{/privacy}","received_events_url":"https://api.github.com/users/anusudarsan/received_events","type":"User","site_admin":false},"body":"looks like this is the same code as the check in AD? Do you think we can just move it to the LdapFilter?","created_at":"2016-08-02T20:39:26Z","updated_at":"2016-08-02T20:39:26Z","html_url":"https://github.com/Teradata/presto/pull/290#discussion_r73232627","pull_request_url":"https://api.github.com/repos/Teradata/presto/pulls/290","_links":{"self":{"href":"https://api.github.com/repos/Teradata/presto/pulls/comments/73232627"},"html":{"href":"https://github.com/Teradata/presto/pull/290#discussion_r73232627"},"pull_request":{"href":"https://api.github.com/repos/Teradata/presto/pulls/290"}}},"pull_request":{"url":"https://api.github.com/repos/Teradata/presto/pulls/290","id":79796502,"html_url":"https://github.com/Teradata/presto/pull/290","diff_url":"https://github.com/Teradata/presto/pull/290.diff","patch_url":"https://github.com/Teradata/presto/pull/290.patch","issue_url":"https://api.github.com/repos/Teradata/presto/issues/290","number":290,"state":"open","locked":false,"title":"Implement group based authorization for openLDAP","user":{"login":"sanjay990","id":7615206,"avatar_url":"https://avatars.githubusercontent.com/u/7615206?v=3","gravatar_id":"","url":"https://api.github.com/users/sanjay990","html_url":"https://github.com/sanjay990","followers_url":"https://api.github.com/users/sanjay990/followers","following_url":"https://api.github.com/users/sanjay990/following{/other_user}","gists_url":"https://api.github.com/users/sanjay990/gists{/gist_id}","starred_url":"https://api.github.com/users/sanjay990/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sanjay990/subscriptions","organizations_url":"https://api.github.com/users/sanjay990/orgs","repos_url":"https://api.github.com/users/sanjay990/repos","events_url":"https://api.github.com/users/sanjay990/events{/privacy}","received_events_url":"https://api.github.com/users/sanjay990/received_events","type":"User","site_admin":false},"body":"Once the user's password is validated, the user's credentials will be\r\nused to check if the user belongs to a particular group. The server\r\nproperty 'authentication.ldap.group-dn' must have the group's\r\ndistinguished name.\r\n\r\nThis commit handles group check for OpenLDAP.","created_at":"2016-08-02T19:45:56Z","updated_at":"2016-08-02T20:39:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5b101c65345321b734bddd8c585a51ef272c06b7","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Teradata/presto/pulls/290/commits","review_comments_url":"https://api.github.com/repos/Teradata/presto/pulls/290/comments","review_comment_url":"https://api.github.com/repos/Teradata/presto/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Teradata/presto/issues/290/comments","statuses_url":"https://api.github.com/repos/Teradata/presto/statuses/1a28be0f797ae873437a637140e80e3ddddf2e47","head":{"label":"Teradata:group_based_authentication_openldap","ref":"group_based_authentication_openldap","sha":"1a28be0f797ae873437a637140e80e3ddddf2e47","user":{"login":"Teradata","id":1615979,"avatar_url":"https://avatars.githubusercontent.com/u/1615979?v=3","gravatar_id":"","url":"https://api.github.com/users/Teradata","html_url":"https://github.com/Teradata","followers_url":"https://api.github.com/users/Teradata/followers","following_url":"https://api.github.com/users/Teradata/following{/other_user}","gists_url":"https://api.github.com/users/Teradata/gists{/gist_id}","starred_url":"https://api.github.com/users/Teradata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Teradata/subscriptions","organizations_url":"https://api.github.com/users/Teradata/orgs","repos_url":"https://api.github.com/users/Teradata/repos","events_url":"https://api.github.com/users/Teradata/events{/privacy}","received_events_url":"https://api.github.com/users/Teradata/received_events","type":"Organization","site_admin":false},"repo":{"id":36903368,"name":"presto","full_name":"Teradata/presto","owner":{"login":"Teradata","id":1615979,"avatar_url":"https://avatars.githubusercontent.com/u/1615979?v=3","gravatar_id":"","url":"https://api.github.com/users/Teradata","html_url":"https://github.com/Teradata","followers_url":"https://api.github.com/users/Teradata/followers","following_url":"https://api.github.com/users/Teradata/following{/other_user}","gists_url":"https://api.github.com/users/Teradata/gists{/gist_id}","starred_url":"https://api.github.com/users/Teradata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Teradata/subscriptions","organizations_url":"https://api.github.com/users/Teradata/orgs","repos_url":"https://api.github.com/users/Teradata/repos","events_url":"https://api.github.com/users/Teradata/events{/privacy}","received_events_url":"https://api.github.com/users/Teradata/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Teradata/presto","description":"Teradata Distribution of Presto -- A Distributed SQL Query Engine for Big Data","fork":true,"url":"https://api.github.com/repos/Teradata/presto","forks_url":"https://api.github.com/repos/Teradata/presto/forks","keys_url":"https://api.github.com/repos/Teradata/presto/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Teradata/presto/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Teradata/presto/teams","hooks_url":"https://api.github.com/repos/Teradata/presto/hooks","issue_events_url":"https://api.github.com/repos/Teradata/presto/issues/events{/number}","events_url":"https://api.github.com/repos/Teradata/presto/events","assignees_url":"https://api.github.com/repos/Teradata/presto/assignees{/user}","branches_url":"https://api.github.com/repos/Teradata/presto/branches{/branch}","tags_url":"https://api.github.com/repos/Teradata/presto/tags","blobs_url":"https://api.github.com/repos/Teradata/presto/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Teradata/presto/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Teradata/presto/git/refs{/sha}","trees_url":"https://api.github.com/repos/Teradata/presto/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Teradata/presto/statuses/{sha}","languages_url":"https://api.github.com/repos/Teradata/presto/languages","stargazers_url":"https://api.github.com/repos/Teradata/presto/stargazers","contributors_url":"https://api.github.com/repos/Teradata/presto/contributors","subscribers_url":"https://api.github.com/repos/Teradata/presto/subscribers","subscription_url":"https://api.github.com/repos/Teradata/presto/subscription","commits_url":"https://api.github.com/repos/Teradata/presto/commits{/sha}","git_commits_url":"https://api.github.com/repos/Teradata/presto/git/commits{/sha}","comments_url":"https://api.github.com/repos/Teradata/presto/comments{/number}","issue_comment_url":"https://api.github.com/repos/Teradata/presto/issues/comments{/number}","contents_url":"https://api.github.com/repos/Teradata/presto/contents/{+path}","compare_url":"https://api.github.com/repos/Teradata/presto/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Teradata/presto/merges","archive_url":"https://api.github.com/repos/Teradata/presto/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Teradata/presto/downloads","issues_url":"https://api.github.com/repos/Teradata/presto/issues{/number}","pulls_url":"https://api.github.com/repos/Teradata/presto/pulls{/number}","milestones_url":"https://api.github.com/repos/Teradata/presto/milestones{/number}","notifications_url":"https://api.github.com/repos/Teradata/presto/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Teradata/presto/labels{/name}","releases_url":"https://api.github.com/repos/Teradata/presto/releases{/id}","deployments_url":"https://api.github.com/repos/Teradata/presto/deployments","created_at":"2015-06-05T00:38:37Z","updated_at":"2016-07-07T14:06:14Z","pushed_at":"2016-08-02T20:17:13Z","git_url":"git://github.com/Teradata/presto.git","ssh_url":"git@github.com:Teradata/presto.git","clone_url":"https://github.com/Teradata/presto.git","svn_url":"https://github.com/Teradata/presto","homepage":"http://www.teradata.com/presto","size":152292,"stargazers_count":52,"watchers_count":52,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":9,"mirror_url":null,"open_issues_count":13,"forks":9,"open_issues":13,"watchers":52,"default_branch":"master"}},"base":{"label":"Teradata:ldap-product-tests","ref":"ldap-product-tests","sha":"9ff83114f3695f98ff5e19313d08b21a961e354c","user":{"login":"Teradata","id":1615979,"avatar_url":"https://avatars.githubusercontent.com/u/1615979?v=3","gravatar_id":"","url":"https://api.github.com/users/Teradata","html_url":"https://github.com/Teradata","followers_url":"https://api.github.com/users/Teradata/followers","following_url":"https://api.github.com/users/Teradata/following{/other_user}","gists_url":"https://api.github.com/users/Teradata/gists{/gist_id}","starred_url":"https://api.github.com/users/Teradata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Teradata/subscriptions","organizations_url":"https://api.github.com/users/Teradata/orgs","repos_url":"https://api.github.com/users/Teradata/repos","events_url":"https://api.github.com/users/Teradata/events{/privacy}","received_events_url":"https://api.github.com/users/Teradata/received_events","type":"Organization","site_admin":false},"repo":{"id":36903368,"name":"presto","full_name":"Teradata/presto","owner":{"login":"Teradata","id":1615979,"avatar_url":"https://avatars.githubusercontent.com/u/1615979?v=3","gravatar_id":"","url":"https://api.github.com/users/Teradata","html_url":"https://github.com/Teradata","followers_url":"https://api.github.com/users/Teradata/followers","following_url":"https://api.github.com/users/Teradata/following{/other_user}","gists_url":"https://api.github.com/users/Teradata/gists{/gist_id}","starred_url":"https://api.github.com/users/Teradata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Teradata/subscriptions","organizations_url":"https://api.github.com/users/Teradata/orgs","repos_url":"https://api.github.com/users/Teradata/repos","events_url":"https://api.github.com/users/Teradata/events{/privacy}","received_events_url":"https://api.github.com/users/Teradata/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Teradata/presto","description":"Teradata Distribution of Presto -- A Distributed SQL Query Engine for Big Data","fork":true,"url":"https://api.github.com/repos/Teradata/presto","forks_url":"https://api.github.com/repos/Teradata/presto/forks","keys_url":"https://api.github.com/repos/Teradata/presto/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Teradata/presto/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Teradata/presto/teams","hooks_url":"https://api.github.com/repos/Teradata/presto/hooks","issue_events_url":"https://api.github.com/repos/Teradata/presto/issues/events{/number}","events_url":"https://api.github.com/repos/Teradata/presto/events","assignees_url":"https://api.github.com/repos/Teradata/presto/assignees{/user}","branches_url":"https://api.github.com/repos/Teradata/presto/branches{/branch}","tags_url":"https://api.github.com/repos/Teradata/presto/tags","blobs_url":"https://api.github.com/repos/Teradata/presto/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Teradata/presto/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Teradata/presto/git/refs{/sha}","trees_url":"https://api.github.com/repos/Teradata/presto/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Teradata/presto/statuses/{sha}","languages_url":"https://api.github.com/repos/Teradata/presto/languages","stargazers_url":"https://api.github.com/repos/Teradata/presto/stargazers","contributors_url":"https://api.github.com/repos/Teradata/presto/contributors","subscribers_url":"https://api.github.com/repos/Teradata/presto/subscribers","subscription_url":"https://api.github.com/repos/Teradata/presto/subscription","commits_url":"https://api.github.com/repos/Teradata/presto/commits{/sha}","git_commits_url":"https://api.github.com/repos/Teradata/presto/git/commits{/sha}","comments_url":"https://api.github.com/repos/Teradata/presto/comments{/number}","issue_comment_url":"https://api.github.com/repos/Teradata/presto/issues/comments{/number}","contents_url":"https://api.github.com/repos/Teradata/presto/contents/{+path}","compare_url":"https://api.github.com/repos/Teradata/presto/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Teradata/presto/merges","archive_url":"https://api.github.com/repos/Teradata/presto/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Teradata/presto/downloads","issues_url":"https://api.github.com/repos/Teradata/presto/issues{/number}","pulls_url":"https://api.github.com/repos/Teradata/presto/pulls{/number}","milestones_url":"https://api.github.com/repos/Teradata/presto/milestones{/number}","notifications_url":"https://api.github.com/repos/Teradata/presto/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Teradata/presto/labels{/name}","releases_url":"https://api.github.com/repos/Teradata/presto/releases{/id}","deployments_url":"https://api.github.com/repos/Teradata/presto/deployments","created_at":"2015-06-05T00:38:37Z","updated_at":"2016-07-07T14:06:14Z","pushed_at":"2016-08-02T20:17:13Z","git_url":"git://github.com/Teradata/presto.git","ssh_url":"git@github.com:Teradata/presto.git","clone_url":"https://github.com/Teradata/presto.git","svn_url":"https://github.com/Teradata/presto","homepage":"http://www.teradata.com/presto","size":152292,"stargazers_count":52,"watchers_count":52,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":9,"mirror_url":null,"open_issues_count":13,"forks":9,"open_issues":13,"watchers":52,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Teradata/presto/pulls/290"},"html":{"href":"https://github.com/Teradata/presto/pull/290"},"issue":{"href":"https://api.github.com/repos/Teradata/presto/issues/290"},"comments":{"href":"https://api.github.com/repos/Teradata/presto/issues/290/comments"},"review_comments":{"href":"https://api.github.com/repos/Teradata/presto/pulls/290/comments"},"review_comment":{"href":"https://api.github.com/repos/Teradata/presto/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Teradata/presto/pulls/290/commits"},"statuses":{"href":"https://api.github.com/repos/Teradata/presto/statuses/1a28be0f797ae873437a637140e80e3ddddf2e47"}}}}
{"actor":{"display_login":"anusudarsan"}}