在 PAM 角色激活期间或在 SSPR 中通过 API 使用自定义多重身份验证提供程序

MIM 客户在 SSPR 和 PAM 方案中有两种多重身份验证选项:

  • 使用自定义的一次性密码传递提供程序,该提供程序仅适用于 MIM SSPR 场景,并在指南中记录如何使用 OTP SMS Gate 配置 Self-Service 密码重置
  • 使用自定义多重身份验证电话提供商。 这同时适用于 MIM SSPR 与 PAM 场景,如本文所述

本文概述了如何通过 API 和客户开发的集成 SDK 将 MIM 与自定义多重身份验证提供程序配合使用。

先决条件

若要将自定义多重身份验证提供程序 API 与 MIM 配合使用,需要:

  • 所有候选用户的电话号码
  • MIM 修补程序 4.5.202.0 或更高版本 - 请参阅版本历史记录中的公告
  • 为 SSPR 或 PAM 配置的 MIM 服务

使用自定义多重身份验证代码的方法

步骤 1:确保 MIM 服务版本为 4.5.202.0 或更高版本

下载并安装 MIM 修补程序 4.5.202.0 或更高版本。

步骤 2:创建实现 IPhoneServiceProvider 接口的 DLL

DLL 必须包含一个实现三个方法的类:

  • InitiateCall:MIM 服务将调用此方法。 该服务将电话号码和请求 ID 作为参数传递。 该方法必须返回 PhoneCallStatusPendingSuccessFailed
  • GetCallStatus:如果先前调用 initiateCall 返回 Pending,MIM 服务将调用此方法。 此方法还返回 PhoneCallStatusPendingSuccessFailed的值。
  • GetFailureMessage:如果先前调用 InitiateCallGetCallStatus 返回 Failed,MIM 服务将调用此方法。 此方法返回诊断消息。

这些方法的实现必须具备线程安全性,且 GetCallStatusGetFailureMessage 的实现不能假定它们会由先前调用 InitiateCall 的同一线程进行调用。

将 DLL C:\Program Files\Microsoft Forefront Identity Manager\2010\Service\ 存储在目录中。

可以使用 Visual Studio 2010 或更高版本编译的示例代码。

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Microsoft.IdentityManagement.PhoneServiceProvider;

namespace CustomPhoneGate
{
    public class CustomPhoneGate: IPhoneServiceProvider
    {
        string path = @"c:\Test\phone.txt";
        public PhoneCallStatus GetCallStatus(string callId)
        {
            int res = 2;
            foreach (string line in File.ReadAllLines(path))
            {
                var info = line.Split(new char[] { ';' });
                if (string.Compare(info[0], callId) == 0)
                {
                    if (info.Length > 2)
                    {
                        bool b = Int32.TryParse(info[2], out res);
                        if (!b)
                        {
                            res = 2;
                        }
                    }
                    break;
                }
            }
            switch(res)
            {
                case 0:
                    return PhoneCallStatus.Pending;
                case 1:
                    return PhoneCallStatus.Success;
                case 2:
                    return PhoneCallStatus.Failed;
                default:
                    return PhoneCallStatus.Failed;
            }       
        }
        public string GetFailureMessage(string callId)
        {
            string res = "Call ID is not found";
            foreach (string line in File.ReadAllLines(path))
            {
                var info = line.Split(new char[] { ';' });
                if (string.Compare(info[0], callId) == 0)
                {
                    if (info.Length > 2)
                    {
                        res = info[3];
                    }
                    else
                    {
                        res = "Description is not found";
                    }
                    break;
                }
            }
            return res;            
        }
        
        public PhoneCallStatus InitiateCall(string phoneNumber, Guid requestId, Dictionary<string,object> deliveryAttributes)
        {
            // Here should be some logic for performing voice call
            // For testing purposes we just write details in file             
            string info = string.Format("{0};{1};{2};{3}", requestId, phoneNumber, 0, string.Empty);
            using (StreamWriter sw = File.AppendText(path))
            {
                sw.WriteLine(info);                
            }
            return PhoneCallStatus.Pending;    
        }
    }
}

步骤 3:保存现有的 MfaSettings

备份位于"C:\Program Files\Microsoft Forefront Identity Manager\2010\Service"文件夹中的 MfaSettings.xml。

步骤 4:编辑 MfaSettings.xml 文件

更新或清除以下行:

  • 删除/清除所有配置条目行

  • 使用自定义电话提供程序将以下行更新或添加到 MfaSettings.xml 中
    <CustomPhoneProvider>C:\Program Files\Microsoft Forefront Identity Manager\2010\Service\CustomPhoneGate.dll</CustomPhoneProvider>

步骤 5:重启 MIM 服务

服务重启后,使用 SSPR 和/或 PAM 通过自定义标识提供者验证功能。

注释

若要还原设置,请将 MfaSettings.xml 替换为步骤 3 中的备份文件

后续步骤