/// <summary> /// Creates an account instance for a given server instance. /// </summary> /// <param name="server"> /// The server instance. /// </param> /// <param name="username"> /// The username. /// </param> /// <param name="password"> /// The password. /// </param> /// <param name="rasApplicationId"> /// The ras application identifier. /// </param> /// <param name="passwordCheck"> /// if set to <c>true</c> for [password check]. /// </param> /// <returns> /// the account instance /// </returns> public static async Task <ServerAccount> AccountForServer( RemoteServer server, string username, string password, string rasApplicationId, bool passwordCheck) { var localAccount = await LocalAccountForServer(server, username, rasApplicationId); if (!passwordCheck) { return(localAccount); } if (localAccount != null && localAccount.PasswordMatch(password)) { return(localAccount); } return(null); }
/// <summary> /// Compares to servers for equivalence /// </summary> /// <param name="other">The server to be compared to</param> /// <returns>True of the two servers are equaivalent</returns> public bool IsEquivalent(RemoteServer other) { return(this.ServerUrl.Equals(other.ServerUrl) && this.Name == other.Name && this.ServerIdentification == other.ServerIdentification); }
/// <summary> /// Initializes a new instance of the <see cref="ServerAccount"/> class. /// </summary> /// <param name="server"> /// The server. /// </param> /// <param name="username"> /// The username. /// </param> public ServerAccount(RemoteServer server, string username) : this(server, username, null, null, null) { }
/// <summary> /// Creates the remote server from URI data. /// </summary> /// <param name="uri">The URI.</param> /// <returns></returns> public static RemoteServer CreateRemoteServerFromUriData(Uri uri) { var queryDict = uri.ExtractQueryString(); var remoteServer = new RemoteServer { Uri = uri }; var serverIdentifier = queryDict.ValueOrDefault("identification"); var serverName = queryDict.ValueOrDefault("name"); var serverUrlString = queryDict.ValueOrDefault("url"); var authenticationType = queryDict.ValueOrDefault("authenticationType"); var networkUsername = queryDict.ValueOrDefault("networkUsername"); var networkPassword = queryDict.ValueOrDefault("networkPassword"); var defaultErrorReportEmailAddress = queryDict.ValueOrDefault("defaultErrorReportEmailAddress"); var siteMinderUrl = queryDict.ValueOrDefault("siteMinderURL"); var userAgent = queryDict.ValueOrDefault("userAgent"); var disableChangePasswordString = queryDict.ValueOrDefault("disableChangePassword"); var initialUserName = queryDict.ValueOrDefault("username"); var loginMode = queryDict.ValueOrDefault("loginMode"); var azureTenantId = queryDict.ValueOrDefault("azureTenantId"); var azureApplictionId = queryDict.ValueOrDefault("azureApplictionId"); var azureReturnUri = queryDict.ValueOrDefault("azureReturnUri"); if (!string.IsNullOrEmpty(serverIdentifier)) { remoteServer.ServerIdentification = serverIdentifier; } if (!string.IsNullOrEmpty(serverName)) { remoteServer.Name = serverName; } if (!string.IsNullOrEmpty(serverUrlString)) { if (!serverUrlString.EndsWith(@"/", StringComparison.CurrentCulture)) { serverUrlString += @"/"; } remoteServer.ServerUrl = new Uri(serverUrlString); remoteServer.OriginalServerUrl = new Uri(serverUrlString + @"\login"); } if (!string.IsNullOrEmpty(authenticationType)) { remoteServer.AuthenticationType = ParseAuthenticationType(authenticationType); } if (!string.IsNullOrEmpty(networkUsername) && !string.IsNullOrEmpty(networkPassword)) { remoteServer.NetworkUsername = networkUsername; remoteServer.NetworkPassword = networkPassword; } if (!string.IsNullOrEmpty(siteMinderUrl)) { remoteServer.SiteMinderUrl = siteMinderUrl; } if (!string.IsNullOrEmpty(defaultErrorReportEmailAddress)) { remoteServer.DefaultErrorReportEmailAddress = defaultErrorReportEmailAddress; } if (!string.IsNullOrEmpty(userAgent)) { remoteServer.UserAgent = userAgent; } if (!string.IsNullOrEmpty(loginMode)) { remoteServer.LoginMode = ParseLoginMode(loginMode); } if (!string.IsNullOrEmpty(initialUserName)) { remoteServer.InitialUserName = initialUserName; } if (!string.IsNullOrEmpty(disableChangePasswordString)) { remoteServer.DisableChangePassword = disableChangePasswordString == "true"; } if (!string.IsNullOrEmpty(azureApplictionId)) { remoteServer.AzureApplictionId = azureApplictionId; } if (!string.IsNullOrEmpty(azureTenantId)) { remoteServer.AzureTenantId = azureTenantId; } if (!string.IsNullOrEmpty(azureReturnUri)) { remoteServer.AzureReturnUri = azureReturnUri; } return(remoteServer); }