/// <summary> /// GetCodeWithExternalSystem method implmentation /// </summary> public NotificationStatus GetCodeWithExternalSystem(Registration reg, ExternalOTPProvider externalsys, CultureInfo culture, out int otp) { SMS_strings.Culture = culture; SMSRuntime.Initialize(externalsys); SMSParams Params = new SMSParams(); try { int zotp = GetRandomOTP(); Params.IPhost = SMSRuntime.IPhost; Params.Password = SMSRuntime.Password; Params.SMSText = string.Format(SMS_strings.SMSMessage, externalsys.Company, zotp); Params.PhoneNumber = reg.PhoneNumber; int errorId; if (SMSRuntime.Authenticate(Params, out errorId, externalsys.Timeout)) { otp = zotp; return(NotificationStatus.ResponseSMSOTP); } else { otp = 0; return(NotificationStatus.Error); } } catch (Exception ex) { Log.WriteEntry("SMS SendMessage : \r" + ex.Message, EventLogEntryType.Error, 10000); otp = 0; return(NotificationStatus.Error); } }
/// <summary> /// GetUserCodeWithExternalSystem method implementation for Azure MFA /// </summary> public int GetUserCodeWithExternalSystem(string upn, string phonenumber, string smstext, ExternalOTPProvider externalsys, CultureInfo culture) { SMS_strings.Culture = culture; SMSRuntime.Initialize(externalsys); SMSParams Params = new SMSParams(); try { int otp = GetRandomOTP(); Params.IPhost = SMSRuntime.IPhost; Params.Password = SMSRuntime.Password; Params.SMSText = string.Format(SMS_strings.SMSMessage, externalsys.Company, otp); Params.PhoneNumber = phonenumber; int errorId; if (SMSRuntime.Authenticate(Params, out errorId, externalsys.Timeout)) { return(Convert.ToInt32(otp)); } else { return((int)NotificationStatus.Error); } } catch (Exception ex) { Log.WriteEntry("SMS SendMessage : \r" + ex.Message, EventLogEntryType.Error, 10000); return((int)NotificationStatus.Error); } }