【问题标题】:How can you update gitlab users after changing LDAP OU更改 LDAP OU 后如何更新 gitlab 用户
【发布时间】:2021-07-25 14:18:56
【问题描述】:

我目前正在使用 LDAP 身份验证的环境中使用 gitlab-ce(omnibus,在 Ubuntu VM 上)。 LDAP 管理员最近重新配置了OUs,类似于

ou=temp, ou=users, ou=baseinfrastructureou=users, ou=baseinfrastructure.

现在,当我使用普通用户帐户执行像 git pull 这样简单的操作时,该用户帐户将设置为 ldap_blocked,因为 gitlab 使用 cn 字符串中的 temp 部分查询用户,显然没找到。

有没有办法更新用户或其他东西,所以 gitlab 不再使用 ou=temp, 部分查询?

【问题讨论】:

    标签: gitlab gitlab-ce


    【解决方案1】:

    对于单个用户,您可以使用gitlab-rails console

    找到你的用户:

    user = User.find_by_email("user@email")
    

    获取用户extern_uid:

    user.ldap_identity.extern_uid
    

    上面的打印结果应该类似于:=> "uid=username,ou=people,dc=example,dc=com"

    根据需要更新值:

    user.ldap_identity.extern_uid = "uid=newusername,ou=newpeople,dc=example,dc=com"
    

    验证:

    user.ldap_identity.extern_uid
    => "uid=newusername,ou=newpeople,dc=example,dc=com"
    

    最后保存

    user.save
    

    我相信这个脚本Gitlab rake task to mass update ldap dn 可能对一次更新多个用户有用。

    【讨论】:

      【解决方案2】:

      经过一番搜索,我发现信息存储在identities表中。

      在 gitlab 综合中,您可以使用 gitlab-psql 启动数据库控制台。

      在我的情况下,验证我做正确的事情所需的查询是:

      SELECT external_uid, replace(external_uid, 'ou=temp,', '') FROM identities;
      

      然后通过执行实际替换它们:

      UPDATE identities SET external_uid = replace(external_uid, 'ou=temp,', '');
      

      【讨论】:

        猜你喜欢
        • 2019-06-22
        • 1970-01-01
        • 2019-01-15
        • 2017-05-06
        • 1970-01-01
        • 2016-09-08
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多