diff --git a/src/lib/microsoft-partnercenter.ts b/src/lib/microsoft-partnercenter.ts index 18f461a..290ecba 100644 --- a/src/lib/microsoft-partnercenter.ts +++ b/src/lib/microsoft-partnercenter.ts @@ -88,6 +88,14 @@ export class MicrosoftPartnerCenter extends MicrosoftApiBase { return data } + async getCustomerUserByPrincipalName( + customerId: string, + principalName: string, + ): Promise { + const users = await this.getAllCustomerUsers(customerId) + return users.find((e) => e.userPrincipalName === principalName) + } + async getCustomerUserRoles(customerId: string, userId: string): Promise { const { data } = await this.httpAgent.get( `/customers/${customerId}/users/${userId}/directoryroles`, @@ -95,6 +103,27 @@ export class MicrosoftPartnerCenter extends MicrosoftApiBase { return data.items } + async setCustomerUserPassword( + customerId: string, + userId: string, + password: string, + forceChangePassword: boolean, + ): Promise { + const { data } = await this.httpAgent.patch( + `/customers/${customerId}/users/${userId}/resetpassword`, + { + passwordProfile: { + password, + forceChangePassword, + }, + attributes: { + objectType: 'CustomerUser', + }, + }, + ) + return data + } + async setCustomerUserRole( customerId: string, roleId: string, diff --git a/src/lib/types/users.types.ts b/src/lib/types/users.types.ts index 50554b5..0c48fe9 100644 --- a/src/lib/types/users.types.ts +++ b/src/lib/types/users.types.ts @@ -20,7 +20,7 @@ export interface User { lastName: string displayName: string immutableId: string - passwordProfile: PasswordProfile + passwordProfile?: PasswordProfile lastDirectorySyncTime: null userDomainType: string state: string