@loopback/docs
Version:
Documentation files rendered at [https://loopback.io](https://loopback.io)
81 lines (41 loc) • 1.7 kB
Markdown
---
lang: en
title: 'API docs: authentication.useridentityservice.linkexternalprofile'
keywords: LoopBack 4.0, LoopBack 4, Node.js, TypeScript, OpenAPI
sidebar: lb4_sidebar
editurl: https://github.com/loopbackio/loopback-next/tree/master/packages/authentication
permalink: /doc/en/lb4/apidocs.authentication.useridentityservice.linkexternalprofile.html
---
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [@loopback/authentication](./authentication.md) > [UserIdentityService](./authentication.useridentityservice.md) > [linkExternalProfile](./authentication.useridentityservice.linkexternalprofile.md)
## UserIdentityService.linkExternalProfile() method
link an external profile with an existing local user id.
**Signature:**
```typescript
linkExternalProfile(userId: string, userIdentity: I): Promise<U>;
```
## Parameters
<table><thead><tr><th>
Parameter
</th><th>
Type
</th><th>
Description
</th></tr></thead>
<tbody><tr><td markdown="1">
userId
</td><td markdown="1">
string
</td><td markdown="1">
</td></tr>
<tr><td markdown="1">
userIdentity
</td><td markdown="1">
I
</td><td markdown="1">
</td></tr>
</tbody></table>
**Returns:**
Promise<U>
## Example
async linkExternalProfile(userId: string, ldapUser: LDAPUserIdentity) { return await this.userIdentityRepository.findOrCreate(<!-- -->{ provider: 'ldap', externalId: ldapUser.id, authScheme: 'active-directory', userId: userId, credentials: { distinguishedName: ldapUser.dn, roles: ldapUser.memberof, expirationTime: ldapUser.maxAge<!-- -->} }<!-- -->); } }