You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@linkis.apache.org by pe...@apache.org on 2022/06/23 12:48:10 UTC

[incubator-linkis] branch dev-1.1.3 updated: feat: make sure the ldap url end with '/', avoid problems due to configuration (#2329)

This is an automated email from the ASF dual-hosted git repository.

peacewong pushed a commit to branch dev-1.1.3
in repository https://gitbox.apache.org/repos/asf/incubator-linkis.git


The following commit(s) were added to refs/heads/dev-1.1.3 by this push:
     new 47832f2e1 feat: make sure the ldap url end with '/', avoid problems due to configuration (#2329)
47832f2e1 is described below

commit 47832f2e1671295821fb84c546ec6e0671b4d3fa
Author: Jack Xu <xu...@126.com>
AuthorDate: Thu Jun 23 20:48:04 2022 +0800

    feat: make sure the ldap url end with '/', avoid problems due to configuration (#2329)
---
 .../org/apache/linkis/common/utils/LDAPUtils.scala | 28 +++++++++++-----------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/LDAPUtils.scala b/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/LDAPUtils.scala
index 39a661c62..b38ccf8a6 100644
--- a/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/LDAPUtils.scala
+++ b/linkis-commons/linkis-common/src/main/scala/org/apache/linkis/common/utils/LDAPUtils.scala
@@ -14,23 +14,27 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
- 
-package org.apache.linkis.common.utils
 
-import java.util.Hashtable
+package org.apache.linkis.common.utils
 
+import org.apache.commons.lang3.StringUtils
 import org.apache.linkis.common.conf.CommonVars
+
+import java.util.Hashtable
 import javax.naming.Context
 import javax.naming.ldap.InitialLdapContext
-import org.apache.commons.lang.StringUtils
-
-
 
 object LDAPUtils extends Logging {
 
-  val url =  CommonVars("wds.linkis.ldap.proxy.url", "").getValue
+  // make sure the url end with '/', otherwise may get error providerUrl
+  var url: String = CommonVars("wds.linkis.ldap.proxy.url", "").getValue
+  if (!url.endsWith("/")) {
+    url = url + "/"
+  }
+
   val baseDN = CommonVars("wds.linkis.ldap.proxy.baseDN", "").getValue
   val userNameFormat = CommonVars("wds.linkis.ldap.proxy.userNameFormat", "").getValue
+
   def login(userID: String, password: String): Unit = {
     val env = new Hashtable[String, String]()
     val bindDN = if (StringUtils.isBlank(userNameFormat)) userID else {
@@ -42,14 +46,10 @@ object LDAPUtils extends Logging {
     env.put(Context.PROVIDER_URL, url + baseDN)
     env.put(Context.SECURITY_PRINCIPAL, bindDN)
     env.put(Context.SECURITY_CREDENTIALS, bindPassword)
-    //    Utils.tryCatch {
+
     new InitialLdapContext(env, null)
-    info(s"user $userID login success.")
-    //      true
-    //    } { e =>
-    //        error(s"user $userID login failed.", e)
-    //        false
-    //    }
+    logger.info(s"user $userID login success.")
+
   }
 }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@linkis.apache.org
For additional commands, e-mail: commits-help@linkis.apache.org