此版本的 GitHub Enterprise Server 已于以下日期停止服务 2024-03-26. 即使针对重大安全问题,也不会发布补丁。 为了获得更好的性能、更高的安全性和新功能,请升级到最新版本的 GitHub Enterprise。 如需升级帮助,请联系 GitHub Enterprise 支持。
适用于 LDAP 的 REST API 终结点
使用 REST API 更新 GitHub Enterprise Server 用户或团队与其关联的 LDAP 条目之间的帐户关系,或者排队新同步。
关于 LDAP
可以使用这些终结点更新用户或团队所映射的可分辨名称 (DN)。 请注意,在大多数情况下,必须为 GitHub Enterprise Server 设备启用 LDAP 同步。 即使已禁用 LDAP 同步,也可以在启用 LDAP 后使用“为用户更新 LDAP 映射”终结点。
Update LDAP mapping for a team
Updates the distinguished name (DN) of the LDAP entry to map to a team. LDAP synchronization must be enabled to map LDAP entries to a team. Use the Create a team endpoint to create a team with LDAP mapping.
“Update LDAP mapping for a team”的参数
名称, 类型, 说明 |
---|
accept string Setting to |
名称, 类型, 说明 |
---|
team_id integer 必须The unique identifier of the team. |
名称, 类型, 说明 |
---|
ldap_dn string 必须The distinguished name (DN) of the LDAP entry to map to a team. |
“Update LDAP mapping for a team”的 HTTP 响应状态代码
状态代码 | 说明 |
---|---|
200 | OK |
“Update LDAP mapping for a team”的示例代码
请求示例
curl -L \
-X PATCH \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
http(s)://HOSTNAME/api/v3/admin/ldap/teams/TEAM_ID/mapping \
-d '{"ldap_dn":"cn=Enterprise Ops,ou=teams,dc=github,dc=com"}'
Response
Status: 200
{
"ldap_dn": "cn=Enterprise Ops,ou=teams,dc=github,dc=com",
"id": 1,
"node_id": "MDQ6VGVhbTE=",
"url": "https://HOSTNAME/teams/1",
"html_url": "https://github.com/orgs/github/teams/justice-league",
"name": "Justice League",
"slug": "justice-league",
"description": "A great team.",
"privacy": "closed",
"notification_setting": "notifications_enabled",
"permission": "admin",
"members_url": "https://HOSTNAME/teams/1/members{/member}",
"repositories_url": "https://HOSTNAME/teams/1/repos",
"parent": null
}
Sync LDAP mapping for a team
Note that this API call does not automatically initiate an LDAP sync. Rather, if a 201
is returned, the sync job is queued successfully, and is performed when the instance is ready.
“Sync LDAP mapping for a team”的参数
名称, 类型, 说明 |
---|
accept string Setting to |
名称, 类型, 说明 |
---|
team_id integer 必须The unique identifier of the team. |
“Sync LDAP mapping for a team”的 HTTP 响应状态代码
状态代码 | 说明 |
---|---|
201 | Created |
“Sync LDAP mapping for a team”的示例代码
请求示例
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
http(s)://HOSTNAME/api/v3/admin/ldap/teams/TEAM_ID/sync
Response
Update LDAP mapping for a user
“Update LDAP mapping for a user”的参数
名称, 类型, 说明 |
---|
accept string Setting to |
名称, 类型, 说明 |
---|
username string 必须The handle for the GitHub user account. |
名称, 类型, 说明 |
---|
ldap_dn string 必须The distinguished name (DN) of the LDAP entry to map to a team. |
“Update LDAP mapping for a user”的 HTTP 响应状态代码
状态代码 | 说明 |
---|---|
200 | OK |
“Update LDAP mapping for a user”的示例代码
请求示例
curl -L \
-X PATCH \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
http(s)://HOSTNAME/api/v3/admin/ldap/users/USERNAME/mapping \
-d '{"ldap_dn":"uid=asdf,ou=users,dc=github,dc=com"}'
Response
Status: 200
{
"ldap_dn": "uid=asdf,ou=users,dc=github,dc=com",
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://HOSTNAME/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://HOSTNAME/users/octocat/followers",
"following_url": "https://HOSTNAME/users/octocat/following{/other_user}",
"gists_url": "https://HOSTNAME/users/octocat/gists{/gist_id}",
"starred_url": "https://HOSTNAME/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://HOSTNAME/users/octocat/subscriptions",
"organizations_url": "https://HOSTNAME/users/octocat/orgs",
"repos_url": "https://HOSTNAME/users/octocat/repos",
"events_url": "https://HOSTNAME/users/octocat/events{/privacy}",
"received_events_url": "https://HOSTNAME/users/octocat/received_events",
"type": "User",
"site_admin": false,
"name": "monalisa octocat",
"company": "GitHub",
"blog": "https://github.com/blog",
"location": "San Francisco",
"email": "octocat@github.com",
"hireable": false,
"bio": "There once was...",
"twitter_username": "monatheoctocat",
"public_repos": 2,
"public_gists": 1,
"followers": 20,
"following": 0,
"created_at": "2008-01-14T04:33:35Z",
"updated_at": "2008-01-14T04:33:35Z",
"private_gists": 81,
"total_private_repos": 100,
"owned_private_repos": 100,
"disk_usage": 10000,
"collaborators": 8,
"two_factor_authentication": true,
"plan": {
"name": "Medium",
"space": 400,
"private_repos": 20,
"collaborators": 0
}
}
Sync LDAP mapping for a user
Note that this API call does not automatically initiate an LDAP sync. Rather, if a 201
is returned, the sync job is queued successfully, and is performed when the instance is ready.
“Sync LDAP mapping for a user”的参数
名称, 类型, 说明 |
---|
accept string Setting to |
名称, 类型, 说明 |
---|
username string 必须The handle for the GitHub user account. |
“Sync LDAP mapping for a user”的 HTTP 响应状态代码
状态代码 | 说明 |
---|---|
201 | Created |
“Sync LDAP mapping for a user”的示例代码
请求示例
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
http(s)://HOSTNAME/api/v3/admin/ldap/users/USERNAME/sync
Response