6.4.1.13 可插入身份验证系统变量

除非安装了适当的服务器端插件,否则这些变量不可用:

  • authentication_ldap_sasl用于名称格式为authentication_ldap_sasl_xxx的系统变量

  • authentication_ldap_simple用于名称格式为authentication_ldap_simple_xxx的系统变量

table6.20 身份验证插件系统变量摘要

NameCmd-LineOption FileSystem VarStatus VarVar ScopeDynamic
authentication_ldap_sasl_auth_method_nameYesYesYesGlobalYes
authentication_ldap_sasl_bind_base_dnYesYesYesGlobalYes
authentication_ldap_sasl_bind_root_dnYesYesYesGlobalYes
authentication_ldap_sasl_bind_root_pwdYesYesYesGlobalYes
authentication_ldap_sasl_ca_pathYesYesYesGlobalYes
authentication_ldap_sasl_group_search_attrYesYesYesGlobalYes
authentication_ldap_sasl_group_search_filterYesYesYesGlobalYes
authentication_ldap_sasl_init_pool_sizeYesYesYesGlobalYes
authentication_ldap_sasl_log_statusYesYesYesGlobalYes
authentication_ldap_sasl_max_pool_sizeYesYesYesGlobalYes
authentication_ldap_sasl_server_hostYesYesYesGlobalYes
authentication_ldap_sasl_server_portYesYesYesGlobalYes
authentication_ldap_sasl_tlsYesYesYesGlobalYes
authentication_ldap_sasl_user_search_attrYesYesYesGlobalYes
authentication_ldap_simple_auth_method_nameYesYesYesGlobalYes
authentication_ldap_simple_bind_base_dnYesYesYesGlobalYes
authentication_ldap_simple_bind_root_dnYesYesYesGlobalYes
authentication_ldap_simple_bind_root_pwdYesYesYesGlobalYes
authentication_ldap_simple_ca_pathYesYesYesGlobalYes
authentication_ldap_simple_group_search_attrYesYesYesGlobalYes
authentication_ldap_simple_group_search_filterYesYesYesGlobalYes
authentication_ldap_simple_init_pool_sizeYesYesYesGlobalYes
authentication_ldap_simple_log_statusYesYesYesGlobalYes
authentication_ldap_simple_max_pool_sizeYesYesYesGlobalYes
authentication_ldap_simple_server_hostYesYesYesGlobalYes
authentication_ldap_simple_server_portYesYesYesGlobalYes
authentication_ldap_simple_tlsYesYesYesGlobalYes
authentication_ldap_simple_user_search_attrYesYesYesGlobalYes
authentication_windows_log_levelYesYesYesGlobalNo
authentication_windows_use_principal_nameYesYesYesGlobalNo

PropertyValue
Command-Line Format--authentication-ldap-sasl-auth-method-name=value
Introduced5.7.19
System Variableauthentication_ldap_sasl_auth_method_name
ScopeGlobal
DynamicYes
TypeString
Default ValueSCRAM-SHA-1
Valid ValuesSCRAM-SHA-1

对于 SASL LDAP 身份验证,身份验证方法名称。身份验证插件和 LDAP 服务器之间的通信根据此身份验证方法进行,以确保密码安全。

允许使用以下身份验证方法值:

  • SCRAM-SHA-1:使用 SASL 质询-响应机制。

Client 端authentication_ldap_sasl_client插件与 SASL 服务器通信,使用密码来创建质询并获取 SASL 请求缓冲区,然后将该缓冲区传递给服务器端authentication_ldap_sasl插件。Client 端和服务器端 SASL LDAP 插件使用 SASL 消息在 LDAP 协议中安全地传输凭据,以避免在 MySQLClient 端和服务器之间发送明文密码。

PropertyValue
Command-Line Format--authentication-ldap-sasl-bind-base-dn=value
Introduced5.7.19
System Variableauthentication_ldap_sasl_bind_base_dn
ScopeGlobal
DynamicYes
TypeString
Default ValueNULL

对于 SASL LDAP 认证,基本专有名称(DN)。通过将变量锚定在搜索树中的某个位置(“基本”),可以使用该变量来限制搜索范围。

假设一组 LDAP 用户条目的成员各自具有以下形式:

uid=user_name,ou=People,dc=example,dc=com

另一组 LDAP 用户条目的成员每个都具有以下形式:

uid=user_name,ou=Admin,dc=example,dc=com

然后像这样搜索不同的基本 DN 值:

  • 如果基本 DN 为ou=People,dc=example,dc=com:搜索仅在第一组中查找用户条目。

    • 如果基本 DN 为ou=Admin,dc=example,dc=com:搜索仅在第二组中查找用户条目。

    • 如果基本 DN 为ou=dc=example,dc=com:搜索将查找第一组或第二组中的用户条目。

通常,更具体的基本 DN 值会导致搜索速度更快,因为它们对搜索范围的限制更大。

PropertyValue
Command-Line Format--authentication-ldap-sasl-bind-root-dn=value
Introduced5.7.19
System Variableauthentication_ldap_sasl_bind_root_dn
ScopeGlobal
DynamicYes
TypeString
Default ValueNULL

对于 SASL LDAP 身份验证,是根专有名称(DN)。此变量与authentication_ldap_sasl_bind_root_pwd结合使用,作为用于执行搜索目的的 LDAP 服务器身份验证的凭据。身份验证使用一个或两个 LDAP 绑定操作,具体取决于 MySQL 帐户是否命名 LDAP 用户 DN:

  • 如果该帐户未命名用户 DN:authentication_ldap_sasl使用authentication_ldap_sasl_bind_root_dnauthentication_ldap_sasl_bind_root_pwd执行初始 LDAP 绑定。 (默认情况下,它们都为空,因此,如果未设置它们,则 LDAP 服务器必须允许匿名连接.)生成的绑定 LDAP 句柄用于根据 Client 端用户名搜索用户 DN。 authentication_ldap_sasl使用用户 DN 和 Client 端提供的密码执行第二次绑定。

    • 如果该帐户确实为用户 DN 命名:在这种情况下,不需要进行第一次绑定操作。 authentication_ldap_sasl使用用户 DN 和 Client 端提供的密码执行单个绑定。这比 MySQL 帐户未指定 LDAP 用户 DN 的速度要快。
  • authentication_ldap_sasl_bind_root_pwd

PropertyValue
Command-Line Format--authentication-ldap-sasl-bind-root-pwd=value
Introduced5.7.19
System Variableauthentication_ldap_sasl_bind_root_pwd
ScopeGlobal
DynamicYes
TypeString
Default ValueNULL

对于 SASL LDAP 认证,是根专有名称的密码。该变量与authentication_ldap_sasl_bind_root_dn结合使用。请参阅该变量的描述。

PropertyValue
Command-Line Format--authentication-ldap-sasl-ca-path=value
Introduced5.7.19
System Variableauthentication_ldap_sasl_ca_path
ScopeGlobal
DynamicYes
TypeString
Default ValueNULL

对于 SASL LDAP 认证,证书颁发机构文件的绝对路径。如果希望认证插件执行 LDAP 服务器证书的验证,请指定此文件。

Note

除了将authentication_ldap_sasl_ca_path变量设置为文件名之外,还必须将适当的证书颁发机构证书添加到文件中并启用authentication_ldap_sasl_tls系统变量。可以将这些变量设置为覆盖默认的 OpenLDAP TLS 配置。见LDAP 可插拔身份验证和 ldap.conf

PropertyValue
Command-Line Format--authentication-ldap-sasl-group-search-attr=value
Introduced5.7.19
System Variableauthentication_ldap_sasl_group_search_attr
ScopeGlobal
DynamicYes
TypeString
Default Valuecn

对于 SASL LDAP 认证,是在 LDAP 目录条目中指定组名称的属性名称。如果authentication_ldap_sasl_group_search_attr的默认值为cn,则搜索将返回cn值作为组名。例如,如果uid值为user1的 LDAP 条目的cn属性为mygroup,则搜索user1返回mygroup作为组名。

如果不需要组或代理身份验证,则此变量应为空字符串。

从 MySQL 5.7.21 开始,如果组搜索属性为isMemberOf,则 LDAP 身份验证直接检索用户属性isMemberOf的值并将其分配为组信息。如果组搜索属性不是isMemberOf,则 LDAP 认证将搜索用户所属的所有组。 (后者是默认行为.)此行为基于 LDAP 组信息存储的两种方式:1)组条目可以具有名为memberUidmember的属性,其值为用户名; 2)用户条目可以具有名为isMemberOf的属性,其值为组名。

PropertyValue
Command-Line Format--authentication-ldap-sasl-group-search-filter=value
Introduced5.7.21
System Variableauthentication_ldap_sasl_group_search_filter
ScopeGlobal
DynamicYes
TypeString
Default Value(|(&(objectClass=posixGroup)(memberUid=%s))(&(objectClass=group)(member=%s)))

对于 SASL LDAP 身份验证,自定义组搜索过滤器。

从 MySQL 5.7.22 开始,搜索过滤器值可以包含{UA}{UD}table 示法来 table 示用户名和完整的用户 DN。例如,{UA}替换为用户名,例如"admin",而{UD}替换为使用完整的 DN,例如"uid=admin,ou=People,dc=example,dc=com"。以下值是默认值,它同时支持 OpenLDAP 和 Active Directory:

(|(&(objectClass=posixGroup)(memberUid={UA}))
  (&(objectClass=group)(member={UD})))

以前,如果组搜索属性是isMemberOfmemberOf,则将其视为具有组信息的用户属性。但是,在某些情况下,对于用户场景,memberOf是一个简单的用户属性,不包含组信息。为了提高灵 Active,现在可以在组搜索属性中使用可选的{GA}前缀。 (以前,假设组搜索属性为isMemberOf,则将以不同的方式对待.现在,任何带有 {}前缀的组属性都将被视为具有组名称的用户属性.)例如,值为{GA}MemberOf,如果组值是 DN,则从组 DN 返回第一个属性值作为组名。

在 MySQL 5.7.21 中,搜索过滤器使用%stable 示法,将其扩展为 OpenLDAP 的用户名(&(objectClass=posixGroup)(memberUid=%s))和 Active Directory 的完整用户 DN(&(objectClass=group)(member=%s))。

PropertyValue
Command-Line Format--authentication-ldap-sasl-init-pool-size=#
Introduced5.7.19
System Variableauthentication_ldap_sasl_init_pool_size
ScopeGlobal
DynamicYes
TypeInteger
Default Value10
Minimum Value0
Maximum Value32767

对于 SASL LDAP 认证,是到 LDAP 服务器的连接池的初始大小。根据对 LDAP 服务器的并发身份验证请求的平均数量,选择此变量的值。

该插件将authentication_ldap_sasl_init_pool_sizeauthentication_ldap_sasl_max_pool_size一起用于连接池 Management:

插件系统变量设置的更改可能不会影响池中已有的连接。例如,修改 LDAP 服务器主机,端口或 TLS 设置不会影响现有连接。但是,如果原始变量值无效并且无法初始化连接池,则插件将尝试为下一个 LDAP 请求重新初始化池。在这种情况下,新的系统变量值将用于重新初始化尝试。

如果authentication_ldap_sasl_max_pool_size=0禁用池,则插件打开的每个 LDAP 连接都使用系统变量当时具有的值。

PropertyValue
Command-Line Format--authentication-ldap-sasl-log-status=#
Introduced5.7.19
System Variableauthentication_ldap_sasl_log_status
ScopeGlobal
DynamicYes
TypeInteger
Default Value1
Minimum Value1
Maximum Value5

对于 SASL LDAP 身份验证,写入错误日志的消息的日志记录级别。下 table 显示了允许的级别值及其含义。

table6.21 authentication_ldap_sasl_log_status 的日志级别

Option Value记录的消息类型
1No messages
2Error messages
3错误和警告消息
4错误,警告和信息消息
5与上一级别相同,另外还有来自 MySQL 的调试消息

在 Client 端,可以通过设置AUTHENTICATION_LDAP_CLIENT_LOG环境变量将消息记录到标准输出中。允许的值和默认值与authentication_ldap_sasl_log_status相同。

AUTHENTICATION_LDAP_CLIENT_LOG环境变量仅适用于 SASL LDAP 身份验证。它对简单的 LDAP 身份验证无效,因为在这种情况下,Client 端插件是mysql_clear_password,它对 LDAP 操作一无所知。

PropertyValue
Command-Line Format--authentication-ldap-sasl-max-pool-size=#
Introduced5.7.19
System Variableauthentication_ldap_sasl_max_pool_size
ScopeGlobal
DynamicYes
TypeInteger
Default Value1000
Minimum Value0
Maximum Value32767

对于 SASL LDAP 身份验证,与 LDAP 服务器的连接池的最大大小。要禁用连接池,请将此变量设置为 0.

该变量与authentication_ldap_sasl_init_pool_size结合使用。请参阅该变量的描述。

PropertyValue
Command-Line Format--authentication-ldap-sasl-server-host=host_name
Introduced5.7.19
System Variableauthentication_ldap_sasl_server_host
ScopeGlobal
DynamicYes
TypeString

对于 SASL LDAP 身份验证,LDAP 服务器主机。此变量的允许值取决于身份验证方法:

PropertyValue
Command-Line Format--authentication-ldap-sasl-server-port=port_num
Introduced5.7.19
System Variableauthentication_ldap_sasl_server_port
ScopeGlobal
DynamicYes
TypeInteger
Default Value389
Minimum Value1
Maximum Value32376

对于 SASL LDAP 身份验证,LDAP 服务器的 TCP/IP 端口号。

从 MySQL 5.7.25 开始,如果 LDAP 端口号配置为 636 或 3269,则插件将使用 LDAPS(基于 SSL 的 LDAP)而不是 LDAP。 (LDAPS 与startTLS不同.)

PropertyValue
Command-Line Format--authentication-ldap-sasl-tls[={OFF|ON}]
Introduced5.7.19
System Variableauthentication_ldap_sasl_tls
ScopeGlobal
DynamicYes
TypeBoolean
Default ValueOFF

对于 SASL LDAP 认证,插件到 LDAP 服务器的连接是否安全。如果启用此变量,则插件将使用 TLS 安全地连接到 LDAP 服务器。可以将此变量设置为覆盖默认的 OpenLDAP TLS 配置;否则,请参见参考资料。请参见LDAP 可插拔身份验证和 ldap.conf。如果启用此变量,则可能还希望设置authentication_ldap_sasl_ca_path变量。

MySQL LDAP 插件支持 StartTLS 方法,该方法在普通 LDAP 连接之上初始化 TLS。

从 MySQL 5.7.25 开始,可以通过设置authentication_ldap_sasl_server_port系统变量来使用 LDAPS。

PropertyValue
Command-Line Format--authentication-ldap-sasl-user-search-attr=value
Introduced5.7.19
System Variableauthentication_ldap_sasl_user_search_attr
ScopeGlobal
DynamicYes
TypeString
Default Valueuid

对于 SASL LDAP 身份验证,该属性的名称指定 LDAP 目录条目中的用户名。如果未提供用户专有名称,那么身份验证插件将使用此属性搜索名称。例如,如果authentication_ldap_sasl_user_search_attr值为uid,则搜索用户名user1会找到uid值为user1的条目。

PropertyValue
Command-Line Format--authentication-ldap-simple-auth-method-name=value
Introduced5.7.19
System Variableauthentication_ldap_simple_auth_method_name
ScopeGlobal
DynamicYes
TypeString
Default ValueSIMPLE
Valid ValuesSIMPLE

AD-FOREST

对于简单的 LDAP 认证,认证方法名称。身份验证插件和 LDAP 服务器之间的通信根据此身份验证方法进行。

Note

对于所有简单的 LDAP 认证方法,建议还设置 TLS 参数,以要求与 LDAP 服务器的通信通过安全连接进行。

允许使用以下身份验证方法值:

  • SIMPLE:使用简单的 LDAP 身份验证。此方法使用一个或两个 LDAP 绑定操作,具体取决于 MySQL 帐户是否命名 LDAP 用户可分辨名称。请参阅authentication_ldap_simple_bind_root_dn的说明。

    • AD-FORESTSIMPLE的变体,以便身份验证搜索 Active Directory 林中的所有域,对每个 Active Directory 域执行 LDAP 绑定,直到在某个域中找到用户为止。
  • authentication_ldap_simple_bind_base_dn

PropertyValue
Command-Line Format--authentication-ldap-simple-bind-base-dn=value
Introduced5.7.19
System Variableauthentication_ldap_simple_bind_base_dn
ScopeGlobal
DynamicYes
TypeString
Default ValueNULL

对于简单的 LDAP 身份验证,使用基本专有名称(DN)。通过将变量锚定在搜索树中的某个位置(“基本”),可以使用该变量来限制搜索范围。

假设一组 LDAP 用户条目的成员各自具有以下形式:

uid=user_name,ou=People,dc=example,dc=com

另一组 LDAP 用户条目的成员每个都具有以下形式:

uid=user_name,ou=Admin,dc=example,dc=com

然后像这样搜索不同的基本 DN 值:

  • 如果基本 DN 为ou=People,dc=example,dc=com:搜索仅在第一组中查找用户条目。

    • 如果基本 DN 为ou=Admin,dc=example,dc=com:搜索仅在第二组中查找用户条目。

    • 如果基本 DN 为ou=dc=example,dc=com:搜索将查找第一组或第二组中的用户条目。

通常,更具体的基本 DN 值会导致搜索速度更快,因为它们对搜索范围的限制更大。

PropertyValue
Command-Line Format--authentication-ldap-simple-bind-root-dn=value
Introduced5.7.19
System Variableauthentication_ldap_simple_bind_root_dn
ScopeGlobal
DynamicYes
TypeString
Default ValueNULL

对于简单的 LDAP 身份验证,请使用根专有名称(DN)。此变量与authentication_ldap_simple_bind_root_pwd结合使用,作为用于执行搜索目的的 LDAP 服务器身份验证的凭据。身份验证使用一个或两个 LDAP 绑定操作,具体取决于 MySQL 帐户是否命名 LDAP 用户 DN:

  • 如果该帐户未命名用户 DN:authentication_ldap_simple使用authentication_ldap_simple_bind_root_dnauthentication_ldap_simple_bind_root_pwd执行初始 LDAP 绑定。 (默认情况下,它们都为空,因此,如果未设置它们,则 LDAP 服务器必须允许匿名连接.)生成的绑定 LDAP 句柄用于根据 Client 端用户名搜索用户 DN。 authentication_ldap_simple使用用户 DN 和 Client 端提供的密码执行第二次绑定。

    • 如果该帐户确实为用户 DN 命名:在这种情况下,不需要进行第一次绑定操作。 authentication_ldap_simple使用用户 DN 和 Client 端提供的密码执行单个绑定。这比 MySQL 帐户未指定 LDAP 用户 DN 的速度要快。
  • authentication_ldap_simple_bind_root_pwd

PropertyValue
Command-Line Format--authentication-ldap-simple-bind-root-pwd=value
Introduced5.7.19
System Variableauthentication_ldap_simple_bind_root_pwd
ScopeGlobal
DynamicYes
TypeString
Default ValueNULL

对于简单的 LDAP 认证,是根专有名称的密码。该变量与authentication_ldap_simple_bind_root_dn结合使用。请参阅该变量的描述。

PropertyValue
Command-Line Format--authentication-ldap-simple-ca-path=value
Introduced5.7.19
System Variableauthentication_ldap_simple_ca_path
ScopeGlobal
DynamicYes
TypeString
Default ValueNULL

对于简单的 LDAP 认证,证书颁发机构文件的绝对路径。如果希望认证插件执行 LDAP 服务器证书的验证,请指定此文件。

Note

除了将authentication_ldap_simple_ca_path变量设置为文件名之外,还必须将适当的证书颁发机构证书添加到文件中并启用authentication_ldap_simple_tls系统变量。可以将这些变量设置为覆盖默认的 OpenLDAP TLS 配置。见LDAP 可插拔身份验证和 ldap.conf

PropertyValue
Command-Line Format--authentication-ldap-simple-group-search-attr=value
Introduced5.7.19
System Variableauthentication_ldap_simple_group_search_attr
ScopeGlobal
DynamicYes
TypeString
Default Valuecn

对于简单的 LDAP 身份验证,该属性的名称指定 LDAP 目录条目中的组名。如果authentication_ldap_simple_group_search_attr的默认值为cn,则搜索将返回cn值作为组名。例如,如果uid值为user1的 LDAP 条目的cn属性为mygroup,则搜索user1返回mygroup作为组名。

从 MySQL 5.7.21 开始,如果组搜索属性为isMemberOf,则 LDAP 身份验证直接检索用户属性isMemberOf的值并将其分配为组信息。如果组搜索属性不是isMemberOf,则 LDAP 认证将搜索用户所属的所有组。 (后者是默认行为.)此行为基于 LDAP 组信息存储的两种方式:1)组条目可以具有名为memberUidmember的属性,其值为用户名; 2)用户条目可以具有名为isMemberOf的属性,其值为组名。

PropertyValue
Command-Line Format--authentication-ldap-simple-group-search-filter=value
Introduced5.7.21
System Variableauthentication_ldap_simple_group_search_filter
ScopeGlobal
DynamicYes
TypeString
Default Value(|(&(objectClass=posixGroup)(memberUid=%s))(&(objectClass=group)(member=%s)))

对于简单的 LDAP 身份验证,请使用自定义组搜索过滤器。

从 MySQL 5.7.22 开始,搜索过滤器值可以包含{UA}{UD}table 示法来 table 示用户名和完整的用户 DN。例如,{UA}替换为用户名,例如"admin",而{UD}替换为使用完整的 DN,例如"uid=admin,ou=People,dc=example,dc=com"。以下值是默认值,它同时支持 OpenLDAP 和 Active Directory:

(|(&(objectClass=posixGroup)(memberUid={UA}))
  (&(objectClass=group)(member={UD})))

以前,如果组搜索属性是isMemberOfmemberOf,则将其视为具有组信息的用户属性。但是,在某些情况下,对于用户场景,memberOf是一个简单的用户属性,不包含组信息。为了提高灵 Active,现在可以在组搜索属性中使用可选的{GA}前缀。 (以前,假设组搜索属性为isMemberOf,则将以不同的方式对待.现在,任何带有 {}前缀的组属性都将被视为具有组名称的用户属性.)例如,值为{GA}MemberOf,如果组值是 DN,则从组 DN 返回第一个属性值作为组名。

在 MySQL 5.7.21 中,搜索过滤器使用%stable 示法,将其扩展为 OpenLDAP 的用户名(&(objectClass=posixGroup)(memberUid=%s))和 Active Directory 的完整用户 DN(&(objectClass=group)(member=%s))。

PropertyValue
Command-Line Format--authentication-ldap-simple-init-pool-size=#
Introduced5.7.19
System Variableauthentication_ldap_simple_init_pool_size
ScopeGlobal
DynamicYes
TypeInteger
Default Value10
Minimum Value0
Maximum Value32767

对于简单的 LDAP 认证,是到 LDAP 服务器的连接池的初始大小。根据对 LDAP 服务器的并发身份验证请求的平均数量,选择此变量的值。

该插件将authentication_ldap_simple_init_pool_sizeauthentication_ldap_simple_max_pool_size一起用于连接池 Management:

插件系统变量设置的更改可能不会影响池中已有的连接。例如,修改 LDAP 服务器主机,端口或 TLS 设置不会影响现有连接。但是,如果原始变量值无效并且无法初始化连接池,则插件将尝试为下一个 LDAP 请求重新初始化池。在这种情况下,新的系统变量值将用于重新初始化尝试。

如果authentication_ldap_simple_max_pool_size=0禁用池,则插件打开的每个 LDAP 连接都使用系统变量当时具有的值。

PropertyValue
Command-Line Format--authentication-ldap-simple-log-status=#
Introduced5.7.19
System Variableauthentication_ldap_simple_log_status
ScopeGlobal
DynamicYes
TypeInteger
Default Value1
Minimum Value1
Maximum Value5

对于简单的 LDAP 身份验证,写入错误日志的消息的日志记录级别。下 table 显示了允许的级别值及其含义。

table6.22 authentication_ldap_simple_log_status 的日志级别

Option Value记录的消息类型
1No messages
2Error messages
3错误和警告消息
4错误,警告和信息消息
5与上一级别相同,另外还有来自 MySQL 的调试消息

PropertyValue
Command-Line Format--authentication-ldap-simple-max-pool-size=#
Introduced5.7.19
System Variableauthentication_ldap_simple_max_pool_size
ScopeGlobal
DynamicYes
TypeInteger
Default Value1000
Minimum Value0
Maximum Value32767

对于简单的 LDAP 认证,是到 LDAP 服务器的连接池的最大大小。要禁用连接池,请将此变量设置为 0.

该变量与authentication_ldap_simple_init_pool_size结合使用。请参阅该变量的描述。

PropertyValue
Command-Line Format--authentication-ldap-simple-server-host=host_name
Introduced5.7.19
System Variableauthentication_ldap_simple_server_host
ScopeGlobal
DynamicYes
TypeString

对于简单的 LDAP 身份验证,LDAP 服务器主机。此变量的允许值取决于身份验证方法:

Active Directory 林设置可以具有多个域(LDAP 服务器 IP),可以使用 DNS 查找这些域。在 Unix 和类似 Unix 的系统上,可能需要进行一些其他设置才能为带有 SRV 记录的 DNS 服务器配置,该记录为 Active Directory 域指定 LDAP 服务器。有关 DNS SRV 的信息,请参阅RFC 2782

假设您的配置具有以下属性:

  • 提供有关 Active Directory 域信息的名称服务器的 IP 地址为10.172.166.100

    • LDAP 服务器的名称为ldap1.mem.localldap3.mem.local,IP 地址为10.172.166.10110.172.166.103

您希望可以使用 SRV 搜索发现 LDAP 服务器。例如,在命令行上,如下所示的命令应列出 LDAP 服务器:

host -t SRV _ldap._tcp.mem.local

执行 DNS 配置,如下所示:

  • /etc/resolv.conf上添加一行以指定提供有关 Active Directory 域信息的名称服务器:
nameserver 10.172.166.100
  • 使用 LDAP 服务器的 SRV 记录为名称服务器配置适当的区域文件:
_ldap._tcp.mem.local. 86400 IN SRV 0 100 389 ldap1.mem.local.
_ldap._tcp.mem.local. 86400 IN SRV 0 100 389 ldap2.mem.local.
_ldap._tcp.mem.local. 86400 IN SRV 0 100 389 ldap3.mem.local.
  • 如果无法解析服务器主机,则可能有必要在/etc/hosts中指定 LDAP 服务器的 IP 地址。例如,将以下行添加到文件中:
10.172.166.101 ldap1.mem.local
10.172.166.102 ldap2.mem.local
10.172.166.103 ldap3.mem.local

使用如上所述配置的 DNS,服务器端 LDAP 插件可以发现 LDAP 服务器,并尝试在所有域中进行身份验证,直到身份验证成功或没有更多服务器为止。

Windows 不需要如上所述的设置。给定 LDAP 服务器主机的authentication_ldap_simple_server_host值,Windows LDAP 库将搜索所有域并尝试进行身份验证。

PropertyValue
Command-Line Format--authentication-ldap-simple-server-port=port_num
Introduced5.7.19
System Variableauthentication_ldap_simple_server_port
ScopeGlobal
DynamicYes
TypeInteger
Default Value389
Minimum Value1
Maximum Value32376

对于简单的 LDAP 认证,请使用 LDAP 服务器的 TCP/IP 端口号。

从 MySQL 5.7.25 开始,如果 LDAP 端口号配置为 636 或 3269,则插件将使用 LDAPS(基于 SSL 的 LDAP)而不是 LDAP。 (LDAPS 与startTLS不同.)

PropertyValue
Command-Line Format--authentication-ldap-simple-tls[={OFF|ON}]
Introduced5.7.19
System Variableauthentication_ldap_simple_tls
ScopeGlobal
DynamicYes
TypeBoolean
Default ValueOFF

对于简单的 LDAP 身份验证,插件到 LDAP 服务器的连接是否安全。如果启用此变量,则插件将使用 TLS 安全地连接到 LDAP 服务器。可以将此变量设置为覆盖默认的 OpenLDAP TLS 配置;否则,请参见参考资料。请参见LDAP 可插拔身份验证和 ldap.conf。如果启用此变量,则可能还希望设置authentication_ldap_simple_ca_path变量。

MySQL LDAP 插件支持 StartTLS 方法,该方法在普通 LDAP 连接之上初始化 TLS。

从 MySQL 5.7.25 开始,可以通过设置authentication_ldap_simple_server_port系统变量来使用 LDAPS。

PropertyValue
Command-Line Format--authentication-ldap-simple-user-search-attr=value
Introduced5.7.19
System Variableauthentication_ldap_simple_user_search_attr
ScopeGlobal
DynamicYes
TypeString
Default Valueuid

对于简单的 LDAP 身份验证,该属性的名称指定 LDAP 目录条目中的用户名。如果未提供用户专有名称,那么身份验证插件将使用此属性搜索名称。例如,如果authentication_ldap_simple_user_search_attr值为uid,则搜索用户名user1会找到uid值为user1的条目。