opsre / go-ldap-admin

🌉 基于Go+Vue实现的openLDAP后台管理项目
http://ldapdoc.eryajf.net
Apache License 2.0
1.6k stars 267 forks source link

我部署完登录进去创建了一个ou,然后发现后台容器一直在重启,日志报panic: 绑定admin账号异常: LDAP Result Code 49 "Invalid Credentials": #369

Closed fu7100 closed 1 month ago

fu7100 commented 1 month ago

2024-10-10 17:43:30 PANIC common/ldap.go:38 github.com/eryajf/go-ldap-admin/public/common.InitLDAP 绑定admin账号异常: LDAP Result Code 49 "Invalid Credentials": panic: 绑定admin账号异常: LDAP Result Code 49 "Invalid Credentials":

eryajf commented 1 month ago

您好 @fu7100👋,我已收到您的反馈,我将安排时间考虑您提交的信息并进行回复。-- 这条信息是由自动回复的机器人发出的。

Hello @fu7100. I have received your feedback, and I will arrange time to consider the information you submitted and reply. -- This message is sent by an automatic reply robot.

eryajf commented 1 month ago

请再给下详细的部署上下文,如果是通过docker-compose拉起的,是不应该出现这个报错的

myderr commented 1 month ago

请再给下详细的部署上下文,如果是通过docker-compose拉起的,是不应该出现这个报错的

我也是报这个错,mysql版本,只修改了ldap域名相关

[INFO  wait] --------------------------------------------------------
[INFO  wait]  docker-compose-wait 2.12.1
[INFO  wait] ---------------------------
[DEBUG wait] Starting with configuration:
[DEBUG wait]  - Hosts to be waiting for: [mysql:3306, openldap:389]
[DEBUG wait]  - Paths to be waiting for: []
[DEBUG wait]  - Timeout before failure: 30 seconds 
[DEBUG wait]  - TCP connection timeout before retry: 5 seconds 
[DEBUG wait]  - Sleeping time before checking for hosts/paths availability: 0 seconds
[DEBUG wait]  - Sleeping time once all hosts/paths are available: 0 seconds
[DEBUG wait]  - Sleeping time between retries: 1 seconds
[DEBUG wait] --------------------------------------------------------
[INFO  wait] Checking availability of host [mysql:3306]
[INFO  wait] Host [mysql:3306] is now available!
[INFO  wait] --------------------------------------------------------
[INFO  wait] Checking availability of host [ openldap:389]
[INFO  wait] Host [ openldap:389] is now available!
[INFO  wait] --------------------------------------------------------
[INFO  wait] docker-compose-wait - Everything's fine, the application can now start!
[INFO  wait] --------------------------------------------------------
2024-10-11 16:09:26     INFO    common/logger.go:110    github.com/eryajf/go-ldap-admin/public/common.InitLogger        初始化zap日志完成!
2024-10-11 16:09:26     INFO    common/database.go:91   github.com/eryajf/go-ldap-admin/public/common.ConnMysql 初始化mysql数据库完成! dsn: root:******@tcp(mysql:3306)/go_ldap_admin?charset=utf8mb4&collation=utf8mb4_general_ci&parseTime=True&loc=Local&timeout=10000ms
2024-10-11 16:09:26     PANIC   common/ldap.go:38       github.com/eryajf/go-ldap-admin/public/common.InitLDAP  绑定admin账号异常: LDAP Result Code 49 "Invalid Credentials": 
panic: 绑定admin账号异常: LDAP Result Code 49 "Invalid Credentials": 

goroutine 1 [running]:
go.uber.org/zap/zapcore.(*CheckedEntry).Write(0xc00010e600, {0x0, 0x0, 0x0})
        /go/pkg/mod/go.uber.org/zap@v1.19.1/zapcore/entry.go:232 +0x44c
go.uber.org/zap.(*SugaredLogger).log(0xc000010bf0, 0x4, {0x1385d93?, 0xc0000356c0?}, {0xc000627db8?, 0x920f0a?, 0x0?}, {0x0, 0x0, 0x0})
        /go/pkg/mod/go.uber.org/zap@v1.19.1/sugar.go:227 +0xee
go.uber.org/zap.(*SugaredLogger).Panicf(...)
        /go/pkg/mod/go.uber.org/zap@v1.19.1/sugar.go:159
github.com/eryajf/go-ldap-admin/public/common.InitLDAP()
        /app/public/common/ldap.go:38 +0x425
main.main()
        /app/main.go:46 +0x54
eryajf commented 1 month ago

两位,要给你们具体部署过程的上下文,这个错误应该都是配置自行更改,然后程序没有对应上的原因。如果你改了ldap,要看看更改后的配置,是否正确备后端读取到了

myderr commented 1 month ago

两位,要给你们具体部署过程的上下文,这个错误应该都是配置自行更改,然后程序没有对应上的原因。如果你改了ldap,要看看更改后的配置,是否正确备后端读取到了

我使用的一下yaml配置,其中删除首行的version和修改了eryajf.net的值 系统是ubuntu2404,安装的最新的docker和compose

version: '3'
networks:
  go-ldap-admin:
    driver: bridge
services:
  go-ldap-admin:
    image: registry.cn-hangzhou.aliyuncs.com/eryajf/go-ldap-admin
    container_name: go-ldap-admin
    hostname: go-ldap-admin
    restart: always
    environment:
      WAIT_HOSTS: mysql:3306, openldap:389
    ports:
      - 8888:8888
    volumes:
      - ./data/go-ldap-admin:/app/data
    depends_on:
      - mysql
      - openldap
    links:
      - mysql:go-ldap-admin-mysql
      - openldap:go-ldap-admin-openldap
    networks:
      - go-ldap-admin

  mysql:
    image: registry.cn-hangzhou.aliyuncs.com/eryajf/mysql:8.3
    container_name: go-ldap-admin-mysql
    hostname: go-ldap-admin-mysql
    restart: always
    ports:
      - '3306:3306'
    environment:
      TZ: Asia/Shanghai
      MYSQL_ROOT_PASSWORD: 123456
      MYSQL_ROOT_HOST: "%"
      MYSQL_DATABASE: go_ldap_admin
    volumes:
      - ./data/mysql:/var/lib/mysql
    networks:
      - go-ldap-admin

  openldap:
    image: registry.cn-hangzhou.aliyuncs.com/eryajf/openldap:1.4.1
    container_name: go-ldap-admin-openldap
    hostname: go-ldap-admin-openldap
    restart: always
    environment:
      TZ: Asia/Shanghai
      LDAP_ORGANISATION: "eryajf.net"
      LDAP_DOMAIN: "eryajf.net"
      LDAP_ADMIN_PASSWORD: "123456"
    command: [ '--copy-service' ]
    volumes:
      - ./data/openldap/database:/var/lib/ldap
      - ./data/openldap/config:/etc/ldap/slapd.d
    ports:
      - 389:389
    networks:
      - go-ldap-admin

  phpldapadmin:
    image: registry.cn-hangzhou.aliyuncs.com/eryajf/phpldapadmin:0.9.0
    container_name: go-ldap-admin-phpldapadmin
    hostname: go-ldap-admin-phpldapadmin
    restart: always
    environment:
      TZ: Asia/Shanghai
      PHPLDAPADMIN_HTTPS: "false"
      PHPLDAPADMIN_LDAP_HOSTS: go-ldap-admin-openldap
    ports:
      - 8091:80
    volumes:
      - ./data/phpadmin:/var/www/phpldapadmin
    depends_on:
      - openldap
    links:
      - openldap:go-ldap-admin-openldap
    networks:
      - go-ldap-admin
eryajf commented 1 month ago

两位,要给你们具体部署过程的上下文,这个错误应该都是配置自行更改,然后程序没有对应上的原因。如果你改了ldap,要看看更改后的配置,是否正确备后端读取到了

我使用的一下yaml配置,其中删除首行的version和修改了eryajf.net的值 系统是ubuntu2404,安装的最新的docker和compose

version: '3'
networks:
  go-ldap-admin:
    driver: bridge
services:
  go-ldap-admin:
    image: registry.cn-hangzhou.aliyuncs.com/eryajf/go-ldap-admin
    container_name: go-ldap-admin
    hostname: go-ldap-admin
    restart: always
    environment:
      WAIT_HOSTS: mysql:3306, openldap:389
    ports:
      - 8888:8888
    volumes:
      - ./data/go-ldap-admin:/app/data
    depends_on:
      - mysql
      - openldap
    links:
      - mysql:go-ldap-admin-mysql
      - openldap:go-ldap-admin-openldap
    networks:
      - go-ldap-admin

  mysql:
    image: registry.cn-hangzhou.aliyuncs.com/eryajf/mysql:8.3
    container_name: go-ldap-admin-mysql
    hostname: go-ldap-admin-mysql
    restart: always
    ports:
      - '3306:3306'
    environment:
      TZ: Asia/Shanghai
      MYSQL_ROOT_PASSWORD: 123456
      MYSQL_ROOT_HOST: "%"
      MYSQL_DATABASE: go_ldap_admin
    volumes:
      - ./data/mysql:/var/lib/mysql
    networks:
      - go-ldap-admin

  openldap:
    image: registry.cn-hangzhou.aliyuncs.com/eryajf/openldap:1.4.1
    container_name: go-ldap-admin-openldap
    hostname: go-ldap-admin-openldap
    restart: always
    environment:
      TZ: Asia/Shanghai
      LDAP_ORGANISATION: "eryajf.net"
      LDAP_DOMAIN: "eryajf.net"
      LDAP_ADMIN_PASSWORD: "123456"
    command: [ '--copy-service' ]
    volumes:
      - ./data/openldap/database:/var/lib/ldap
      - ./data/openldap/config:/etc/ldap/slapd.d
    ports:
      - 389:389
    networks:
      - go-ldap-admin

  phpldapadmin:
    image: registry.cn-hangzhou.aliyuncs.com/eryajf/phpldapadmin:0.9.0
    container_name: go-ldap-admin-phpldapadmin
    hostname: go-ldap-admin-phpldapadmin
    restart: always
    environment:
      TZ: Asia/Shanghai
      PHPLDAPADMIN_HTTPS: "false"
      PHPLDAPADMIN_LDAP_HOSTS: go-ldap-admin-openldap
    ports:
      - 8091:80
    volumes:
      - ./data/phpadmin:/var/www/phpldapadmin
    depends_on:
      - openldap
    links:
      - openldap:go-ldap-admin-openldap
    networks:
      - go-ldap-admin

你需要参考此文档更改:https://ldapdoc.eryajf.net/pages/adb742/ ,只改这一个地方只是ldap的变了,后端里边使用的默认配置还是 eryajf.net

fu7100 commented 1 month ago

不好意思,我是通过docker-compose启动的,我理解docker-compose启动只需要一个docker-compose.yaml就可以了,不明白这个config.yaml在哪里有使用?

eryajf commented 1 month ago

不好意思,我是通过docker-compose启动的,我理解docker-compose启动只需要一个docker-compose.yaml就可以了,不明白这个config.yaml在哪里有使用?

docker-compose启动是直接启动然后没有更改任何东西吗,麻烦给下具体操作步骤。其实如果你用这个方式拉起,应该是可以直接使用的,不会存在一直重启的问题。

fu7100 commented 1 month ago

不好意思,我是通过docker-compose启动的,我理解docker-compose启动只需要一个docker-compose.yaml就可以了,不明白这个config.yaml在哪里有使用?

docker-compose启动是直接启动然后没有更改任何东西吗,麻烦给下具体操作步骤。其实如果你用这个方式拉起,应该是可以直接使用的,不会存在一直重启的问题。

我就修改了basedn,以及mysql数据库。

version: '3'
networks:
  go-ldap-admin:
    driver: bridge
services:
  go-ldap-admin:
    image: registry.cn-hangzhou.aliyuncs.com/eryajf/go-ldap-admin
    container_name: go-ldap-admin
    hostname: go-ldap-admin
    restart: always
    environment:
      WAIT_HOSTS: openldap:389
      DB_DRIVER: mysql
      # 请修改下面的 MySql 配置,需自行创建数据库和用户
      MYSQL_HOST: 10.10.10.100
      MYSQL_PORT: 3306
      MYSQL_USERNAME: root
      MYSQL_PASSWORD: 123456
      MYSQL_DATABASE: go_ldap_admin
    ports:
      - 8888:8888
    volumes:
      - ./data/go-ldap-admin:/app/data
    depends_on:
      - openldap
    links:
      - openldap:go-ldap-admin-openldap
    networks:
      - go-ldap-admin

  openldap:
    image: registry.cn-hangzhou.aliyuncs.com/eryajf/openldap:1.4.1
    container_name: go-ldap-admin-openldap
    hostname: go-ldap-admin-openldap
    restart: always
    environment:
      TZ: Asia/Shanghai
      LDAP_ORGANISATION: "cloud.cn"
      LDAP_DOMAIN: "cloud.cn"
      LDAP_ADMIN_PASSWORD: "123456"
    command: [ '--copy-service' ]
    volumes:
      - ./data/openldap/database:/var/lib/ldap
      - ./data/openldap/config:/etc/ldap/slapd.d
    ports:
      - 389:389
    networks:
      - go-ldap-admin

  phpldapadmin:
    image: registry.cn-hangzhou.aliyuncs.com/eryajf/phpldapadmin:0.9.0
    container_name: go-ldap-admin-phpldapadmin
    hostname: go-ldap-admin-phpldapadmin
    restart: always
    environment:
      TZ: Asia/Shanghai
      PHPLDAPADMIN_HTTPS: "false"
      PHPLDAPADMIN_LDAP_HOSTS: go-ldap-admin-openldap
    ports:
      - 8091:80
    volumes:
      - ./data/phpadmin:/var/www/phpldapadmin
    depends_on:
      - openldap
    links:
      - openldap:go-ldap-admin-openldap
    networks:
      - go-ldap-admin
eryajf commented 1 month ago

不好意思,我是通过docker-compose启动的,我理解docker-compose启动只需要一个docker-compose.yaml就可以了,不明白这个config.yaml在哪里有使用?

docker-compose启动是直接启动然后没有更改任何东西吗,麻烦给下具体操作步骤。其实如果你用这个方式拉起,应该是可以直接使用的,不会存在一直重启的问题。

我就修改了basedn,以及mysql数据库。

version: '3'
networks:
  go-ldap-admin:
    driver: bridge
services:
  go-ldap-admin:
    image: registry.cn-hangzhou.aliyuncs.com/eryajf/go-ldap-admin
    container_name: go-ldap-admin
    hostname: go-ldap-admin
    restart: always
    environment:
      WAIT_HOSTS: openldap:389
      DB_DRIVER: mysql
      # 请修改下面的 MySql 配置,需自行创建数据库和用户
      MYSQL_HOST: 10.10.10.100
      MYSQL_PORT: 3306
      MYSQL_USERNAME: root
      MYSQL_PASSWORD: 123456
      MYSQL_DATABASE: go_ldap_admin
    ports:
      - 8888:8888
    volumes:
      - ./data/go-ldap-admin:/app/data
    depends_on:
      - openldap
    links:
      - openldap:go-ldap-admin-openldap
    networks:
      - go-ldap-admin

  openldap:
    image: registry.cn-hangzhou.aliyuncs.com/eryajf/openldap:1.4.1
    container_name: go-ldap-admin-openldap
    hostname: go-ldap-admin-openldap
    restart: always
    environment:
      TZ: Asia/Shanghai
      LDAP_ORGANISATION: "cloud.cn"
      LDAP_DOMAIN: "cloud.cn"
      LDAP_ADMIN_PASSWORD: "123456"
    command: [ '--copy-service' ]
    volumes:
      - ./data/openldap/database:/var/lib/ldap
      - ./data/openldap/config:/etc/ldap/slapd.d
    ports:
      - 389:389
    networks:
      - go-ldap-admin

  phpldapadmin:
    image: registry.cn-hangzhou.aliyuncs.com/eryajf/phpldapadmin:0.9.0
    container_name: go-ldap-admin-phpldapadmin
    hostname: go-ldap-admin-phpldapadmin
    restart: always
    environment:
      TZ: Asia/Shanghai
      PHPLDAPADMIN_HTTPS: "false"
      PHPLDAPADMIN_LDAP_HOSTS: go-ldap-admin-openldap
    ports:
      - 8091:80
    volumes:
      - ./data/phpadmin:/var/www/phpldapadmin
    depends_on:
      - openldap
    links:
      - openldap:go-ldap-admin-openldap
    networks:
      - go-ldap-admin

你这个还改掉了LDAP_DOMAIN,此操作不是只改这一个地方就可以的,详见:https://ldapdoc.eryajf.net/pages/adb742/

fu7100 commented 1 month ago

不好意思,我是通过docker-compose启动的,我理解docker-compose启动只需要一个docker-compose.yaml就可以了,不明白这个config.yaml在哪里有使用?

docker-compose启动是直接启动然后没有更改任何东西吗,麻烦给下具体操作步骤。其实如果你用这个方式拉起,应该是可以直接使用的,不会存在一直重启的问题。

我就修改了basedn,以及mysql数据库。

version: '3'
networks:
  go-ldap-admin:
    driver: bridge
services:
  go-ldap-admin:
    image: registry.cn-hangzhou.aliyuncs.com/eryajf/go-ldap-admin
    container_name: go-ldap-admin
    hostname: go-ldap-admin
    restart: always
    environment:
      WAIT_HOSTS: openldap:389
      DB_DRIVER: mysql
      # 请修改下面的 MySql 配置,需自行创建数据库和用户
      MYSQL_HOST: 10.10.10.100
      MYSQL_PORT: 3306
      MYSQL_USERNAME: root
      MYSQL_PASSWORD: 123456
      MYSQL_DATABASE: go_ldap_admin
    ports:
      - 8888:8888
    volumes:
      - ./data/go-ldap-admin:/app/data
    depends_on:
      - openldap
    links:
      - openldap:go-ldap-admin-openldap
    networks:
      - go-ldap-admin

  openldap:
    image: registry.cn-hangzhou.aliyuncs.com/eryajf/openldap:1.4.1
    container_name: go-ldap-admin-openldap
    hostname: go-ldap-admin-openldap
    restart: always
    environment:
      TZ: Asia/Shanghai
      LDAP_ORGANISATION: "cloud.cn"
      LDAP_DOMAIN: "cloud.cn"
      LDAP_ADMIN_PASSWORD: "123456"
    command: [ '--copy-service' ]
    volumes:
      - ./data/openldap/database:/var/lib/ldap
      - ./data/openldap/config:/etc/ldap/slapd.d
    ports:
      - 389:389
    networks:
      - go-ldap-admin

  phpldapadmin:
    image: registry.cn-hangzhou.aliyuncs.com/eryajf/phpldapadmin:0.9.0
    container_name: go-ldap-admin-phpldapadmin
    hostname: go-ldap-admin-phpldapadmin
    restart: always
    environment:
      TZ: Asia/Shanghai
      PHPLDAPADMIN_HTTPS: "false"
      PHPLDAPADMIN_LDAP_HOSTS: go-ldap-admin-openldap
    ports:
      - 8091:80
    volumes:
      - ./data/phpadmin:/var/www/phpldapadmin
    depends_on:
      - openldap
    links:
      - openldap:go-ldap-admin-openldap
    networks:
      - go-ldap-admin

你这个还改掉了LDAP_DOMAIN,此操作不是只改这一个地方就可以的,详见:https://ldapdoc.eryajf.net/pages/adb742/

所以我还是没有懂,你这个config.yaml到底在哪里被用到,docker-compose.yaml中挂载的卷都是./data/xxx目录,没有看到config.yaml是放在哪里?config.yaml到底要如何使用还是说它不是给docker-compose使用的?

eryajf commented 1 month ago

不好意思,我是通过docker-compose启动的,我理解docker-compose启动只需要一个docker-compose.yaml就可以了,不明白这个config.yaml在哪里有使用?

docker-compose启动是直接启动然后没有更改任何东西吗,麻烦给下具体操作步骤。其实如果你用这个方式拉起,应该是可以直接使用的,不会存在一直重启的问题。

我就修改了basedn,以及mysql数据库。

version: '3'
networks:
  go-ldap-admin:
    driver: bridge
services:
  go-ldap-admin:
    image: registry.cn-hangzhou.aliyuncs.com/eryajf/go-ldap-admin
    container_name: go-ldap-admin
    hostname: go-ldap-admin
    restart: always
    environment:
      WAIT_HOSTS: openldap:389
      DB_DRIVER: mysql
      # 请修改下面的 MySql 配置,需自行创建数据库和用户
      MYSQL_HOST: 10.10.10.100
      MYSQL_PORT: 3306
      MYSQL_USERNAME: root
      MYSQL_PASSWORD: 123456
      MYSQL_DATABASE: go_ldap_admin
    ports:
      - 8888:8888
    volumes:
      - ./data/go-ldap-admin:/app/data
    depends_on:
      - openldap
    links:
      - openldap:go-ldap-admin-openldap
    networks:
      - go-ldap-admin

  openldap:
    image: registry.cn-hangzhou.aliyuncs.com/eryajf/openldap:1.4.1
    container_name: go-ldap-admin-openldap
    hostname: go-ldap-admin-openldap
    restart: always
    environment:
      TZ: Asia/Shanghai
      LDAP_ORGANISATION: "cloud.cn"
      LDAP_DOMAIN: "cloud.cn"
      LDAP_ADMIN_PASSWORD: "123456"
    command: [ '--copy-service' ]
    volumes:
      - ./data/openldap/database:/var/lib/ldap
      - ./data/openldap/config:/etc/ldap/slapd.d
    ports:
      - 389:389
    networks:
      - go-ldap-admin

  phpldapadmin:
    image: registry.cn-hangzhou.aliyuncs.com/eryajf/phpldapadmin:0.9.0
    container_name: go-ldap-admin-phpldapadmin
    hostname: go-ldap-admin-phpldapadmin
    restart: always
    environment:
      TZ: Asia/Shanghai
      PHPLDAPADMIN_HTTPS: "false"
      PHPLDAPADMIN_LDAP_HOSTS: go-ldap-admin-openldap
    ports:
      - 8091:80
    volumes:
      - ./data/phpadmin:/var/www/phpldapadmin
    depends_on:
      - openldap
    links:
      - openldap:go-ldap-admin-openldap
    networks:
      - go-ldap-admin

你这个还改掉了LDAP_DOMAIN,此操作不是只改这一个地方就可以的,详见:ldapdoc.eryajf.net/pages/adb742

所以我还是没有懂,你这个config.yaml到底在哪里被用到,docker-compose.yaml中挂载的卷都是./data/xxx目录,没有看到config.yaml是放在哪里?config.yaml到底要如何使用还是说它不是给docker-compose使用的?

回头我把docker-compose改造一下应该就比较清晰了。正确的用法应该是需要从源码里拿到config.yaml,然后挂载进去,这个时候变更就会映射进去了。

eryajf commented 1 month ago

@fu7100 更新了docker-compose配置,使用新配置,可直接更改。