小编Pra*_*790的帖子

使用 goLang 进行 LDAP 身份验证

我正在尝试使用 goLang 对 LDAP 服务器进行身份验证,同时还尝试搜索用户。我是 goLang 和 LDAP 的新手,所以我提取了 GitHub 代码。在尝试使用以下代码时,我在身份验证中遇到错误

func ExampleLDAPClient_Authenticate() {
    client := &ldap.LDAPClient{
        Base:         "cn=admin,dc=testing,dc=io",
        Host:         "52.51.245.219",
        Port:         389,
        UseSSL:       false,
        BindDN:       "cn=admin,dc=testing,dc=io",
        BindPassword: "test123",
        UserFilter:   "(uid='*api*')",
        // GroupFilter:  "(memberUid=%s)",
        Attributes: []string{"givenName", "sn", "mail", "uid"},
    }
    defer client.Close()
    username := "cn=admin,dc=testing,dc=io"
    password := "test123"
    ok, user, err := client.Authenticate(username, password)
    if err != nil {
        log.Fatalf("Error authenticating user %s: %+v", "*cn=admin,dc=testing,dc=io*", err)
    }
    if !ok {
        log.Fatalf("Authenticating failed for user %s", "*cn=admin,dc=testing,dc=io*")
    }
    log.Printf("User: %+v", user) …
Run Code Online (Sandbox Code Playgroud)

ldap go openldap ldap-query

5
推荐指数
1
解决办法
1980
查看次数

如何使用cloudformation模板获取用户数据的输出值?

我有 cloudformation 模板,其中包含两个具有 userdata 属性的实例。

我需要从一个实例的用户数据中获取数据并将其传递给另一个实例的用户数据。

例如(如下),需要从实例1获取“test”,并传递给实例2用户数据。

示例模板:

"instance1": {
  "Type": "AWS::EC2::Instance",
  "Properties": {
"UserData": {
      "Fn::Base64": {
        "Fn::Join": [
          "",
          [
            "#!/bin/bash\n",
            "set -x\n",
            "echo test\n",
          ]]}}}},

"instance2": {
  "Type": "AWS::EC2::Instance",
  "Properties": {
"UserData": {
      "Fn::Base64": {
        "Fn::Join": [
          "",
          [
            "#!/bin/bash\n",
            "set -x\n",
            //fetch the value
          ]]}}}},
Run Code Online (Sandbox Code Playgroud)

instance amazon-web-services user-data aws-cloudformation

5
推荐指数
1
解决办法
1412
查看次数