文章 与 Active Directory 同步会员资料的可编辑字段

ldap.config 文件包含了 Limyee CMS 与您的 LDAP 服务系统将共享的所有属性。通过使用 ldap.config,您可以控制 LDAP 字段在用户个人资料页面上的分组方式以及查看和编辑功能。本文将介绍 ldap.config 中的各种项目。

您可以在 \LimyeeCMS\Web\config(默认路径)中找到 ldap.config。下面我们来看一下默认情况下 ldap.config 中的各个部分:

Connection

LDAP 连接的属性包含以下元素:

属性名称 属性描述
Server LDAP服务器的地址。如果配置为“LDAP:\”或“GC:\”,则根据当前计算机的 Active Directory 域成员身份自动检测目录服务器。
Port LDAP服务器监听请求的端口号。
AdminUserDN 用于连接 LDAP 服务器的用户所使用的标识名。
AdminUserPassword 用于连接 LDAP 服务器的用户所使用的标识名对应的密码。
Authentication 连接将使用的认证类型。默认为“Secure”。设置为“Secure”时,将使用NTLM认证;设置为“SecureSocketsLayer”时,将使用 SSL 加密认证。

多域环境的考虑

要在多域环境中配置 LDAP,您需要将 Limyee CMS 指向顶级域名的全局目录服务器。为此,您需修改 ldap.config 文件中 Ldap/Connection 部分的服务器和端口设置。应将 Server 修改为使用 GC:// 而不是 LDAP://。如果仅使用 LDAP://,将只能查询该特定域内的用户。通过使用全局目录,它还可以查询任何子域中的用户和组。请使用端口 3268 而非端口 389。

<LdapConnection>
   <add key="Server" value="GC://mycompany.com" />
   <add key="Port" value="3268" />
   <add key="Authentication" value="Secure" />
</LdapConnection>

服务器设置区分大小写。请确保在 GC://mycompany.com 设置中的服务器是群集中根域的名称。

目前在使用多域环境时,Limyee CMS 将无法允许用户资料更新。全局目录为只读状态,且 Limyee CMS 不支持对环境中各个域控制器进行更新。为避免出现问题,建议编辑 ldap.config 文件,并将所有属性条目的访问级别设置为“只读”。

在多域环境中,需特别注意不同域之间可能存在的命名冲突。如果两个不同域中都有用户名为“joe”的用户,Limyee CMS 可能无法确定从 LDAP 中应获取哪位用户。

CoreAttributes

以下是 ldap.config 文件中 CoreAttributes 部分的默认示例:

<CoreAttributes
	UserObjectClass="user"
	GroupObjectClass="group"
	GroupNameIdentifier="cn"
	UserEmail="mail"
	StripEmail="false"
	UserMobile="mobile"
	UserDomainName="samaccountname"
	UserCommonName="cn"
	PageSize="1000"
	IncludeSubGroupUsers="false"
	UserSearchBaseDN="cn=Users,dc=example,dc=com"
	GroupSearchBaseDN="ou=Groups,dc=example,dc=com"
	/>

以下是对 CoreAttributes 对象中每个元素的描述:

属性名称 属性描述
UserObjectClass 对应于存储用户类别的LDAP目录。只有在搜索用户时,未使用 objectClass=user 查询 LDAP 源时,才应更改此设置。
GroupObjectClass 对应于存储您组的 LDAP 类别。只有在搜索组时未使用 objectClass=group 查询 LDAP 源时,才应更改此设置。
GroupNameIdentifier 查找组的唯一名称时应使用哪个 LDAP 字段。

UserEmail

查找用户电子邮件地址时应使用哪个 LDAP 字段。

UserDomainName

在引用特定用户域用户名时,应使用哪个 LDAP 字段。我们的示例使用“samaccountname”,它对应一个域用户名,例如“joe”。

UserCommonName

查找用户通用名称时应使用哪个 LDAP 字段。一个示例通用名称可能是“John Doe”。

Contacts

以下是 ldap.config 文件中 Contacts 部分的默认示例:

<Contacts EnableSyncContacts="true" ObjectClass="contact" CommonName="cn" BaseDN="OU=Contacts,DC=example,DC=com">
	<Attribute Name="cn" Value="Limyee$ID" />
	<Attribute Name="name" Value="Limyee$ID" />
	<Attribute Name="displayName" Value="$NAME" />
	<Attribute Name="mail" Value="$EMAIL" />
	<Attribute Name="proxyAddresses" Value="SMTP:$EMAIL" />
	<Attribute Name="targetAddress" Value="smtp:$EMAIL" />
	<Attribute Name="mailNickname" Value="$NAME" />
	<Attribute Name="legacyExchangeDN" Value="/o=Example/ou=Exchange Administrative Group/cn=Recipients/cn=Limyee$ID" />
	<Attribute Name="showInAddressBook" Value="CN=Default Global Address List,CN=All Global Address Lists,CN=Address Lists Container,CN=Example,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=example,DC=com" />
	<Attribute Name="showInAddressBook" Value="CN=All Contacts,CN=All Address Lists,CN=Address Lists Container,CN=Example,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=example,DC=com" />
	<Attribute Name="internetEncoding" Value="1310720" />
	<Attribute Name="msExchRecipientDisplayType" Value="6" />
	<Attribute Name="mAPIRecipient" Value="FALSE" />
</Contacts>

以下是 Contacts 对象的属性名称及其描述:

属性名称 属性描述
EnableSyncContacts 用于确定是否在 Limyee CMS 与 LDAP 源之间同步联系信息。
ObjectClass 对应示例代码库中包含联系信息的类。
CommonName 该值应与存储通用名称的 LDAP 字段相对应。

BaseDN

该值应与您 LDAP 数据源中联系人对象的 base distinguished name 相对应。

以下是 Attribute 对象的属性名称及描述:

属性名称 属性描述
Name 由 Attribute 标签设置的联系人的 LDAP 属性名称。
Value 属性的值。

AttributeGroup

在默认的 ldap.config 文件中,有两个 AttributeGroup 部分,您可能希望对其进行修改。这些部分中的 Attribute 对象控制着 Limyee CMS 内部用户可使用的 LDAP/Active Directory 字段。

以下是 ldap.config 文件中 AttributeGroup 部分的默认示例:

<AttributeGroup Name="Personal Information" Order="1">
    <Attribute Name="displayName" DisplayAs="Name" AccessLevel="ReadWrite" />
    <Attribute Name="mail" DisplayAs="Email" AccessLevel="ReadOnly" />
    <Attribute Name="street" DisplayAs="Address" AccessLevel="ReadWrite" />
    <Attribute Name="l" DisplayAs="City" AccessLevel="ReadWrite" />
    <Attribute Name="st" DisplayAs="State" AccessLevel="ReadWrite" />
    <Attribute Name="postalCode" DisplayAs="Zip Code" AccessLevel="ReadWrite" />
    <Attribute Name="c" DisplayAs="Country/Region" AccessLevel="ReadWrite" />
    <Attribute Name="telephoneNumber" DisplayAs="Telephone Number" AccessLevel="ReadWrite" />
    <Attribute Name="mobile" DisplayAs="Mobile Number" AccessLevel="ReadWrite" />
</AttributeGroup>
<AttributeGroup Name="Company Information" Order="2">
    <Attribute Name="o" DisplayAs="Company" AccessLevel="ReadOnly" />
    <Attribute Name="title" DisplayAs="Title" AccessLevel="ReadWrite" />
    <Attribute Name="departmentNumber" DisplayAs="Department" AccessLevel="ReadWrite" />
    <Attribute Name="physicalDeliveryOfficeName" DisplayAs="Office" AccessLevel="ReadWrite" />
</AttributeGroup>

以下是 AttributeGroup 对象的属性名称及描述:

属性名称 属性描述
Name 将作为用户资料的标签页名称。
Order 控制用户资料中标签页的显示顺序。该值必须在所有 AttributeGroups 中保持唯一。

以下是 Attribute 对象的属性名称及描述:

属性名称 属性描述
Name 所使用的 LDAP 字段名称。
DisplayAs 将在 Limyee CMS 中向用户显示的文本。
AccessLevel 该值控制用户能否读取或编辑用户资料的值。默认值为:ReadOnly。

读写功能需要一个有读写权限的 LDAP 服务账户。

您可以自定义 Limyee CMS 用户资料显示的 LDAP 字段,并根据需要添加或删除项目或整个项目组。例如,如果您的组织高度依赖即时通讯(IM),而员工有时会更改其 IM 地址,您可以考虑在用户资料中创建一个 “IM” 资料组,以便用户可以更新自己的 IM 地址,并查看组织内其他成员的 IM 地址:

首先,你需要创建一个类似以下结构的 AttributeGroup:

<AttributeGroup Name="IM" Order="3">
</AttributeGroup>

上述标记将在用户资料中创建一个标签为“IM”的选项卡。由于默认的 ldap.config 文件中定义了两个 AttributeGroup,我们将把 Order 设置为“3”,使其成为用户资料的第三个选项卡。

接下来,我们需要为员工经常使用的每项即时通讯服务添加 IM 地址字段。标记可能如下所示:

<Attribute Name="msn" DisplayAs="MSN" AccessLevel="ReadOnly" />
<Attribute Name="AOL" DisplayAs="America Online" AccessLevel="ReadWrite" />
<Attribute Name="icq" DisplayAs="ICQ" AccessLevel="ReadWrite" />
<Attribute Name="Yahoo" DisplayAs="Yahoo!" AccessLevel="ReadWrite" />

第一个对象的 AccessLevel  为“ReadOnly”。这意味着用户无法在用户配置文件中修改此值,但可以查看该值。