Exemplo n.º 1
0
 public static UserParameter Create(string connectionString)
 {
     try
     {
         var result = new UserParameter();
         var split  = connectionString.Split(';');
         foreach (var item in split)
         {
             if (item.ToLowerInvariant().StartsWith("userid"))
             {
                 result.UserName = item.Split('=').ElementAtOrDefault(1) ?? String.Empty;
             }
             if (item.ToLowerInvariant().StartsWith("password"))
             {
                 result.Password = item.Split('=').ElementAtOrDefault(1) ?? String.Empty;
             }
             if (item.ToLowerInvariant().StartsWith("url"))
             {
                 result.ConnectUri = item.Split('=').ElementAtOrDefault(1) ?? String.Empty;
             }
             if (item.ToLowerInvariant().StartsWith("isdesktop"))
             {
                 result.UseDesktop = Convert.ToBoolean(item.Split('=').ElementAtOrDefault(1).ToLowerInvariant());
             }
         }
         return(result);
     }
     catch (Exception ex)
     {
         logger.Error(ex, "Could not parse connection string.");
         return(null);
     }
 }
Exemplo n.º 2
0
        public static ConnectionConfig CreateConfig(UserParameter parameter, string app = null)
        {
            var uri    = new Uri(parameter.ConnectUri);
            var result = new ConnectionConfig()
            {
                ServerUri = uri,
                App       = app ?? "engineData",
            };

            if (!parameter.UseDesktop)
            {
                result.Credentials = new ConnCredentials()
                {
                    Type  = QlikCredentialType.CERTIFICATE,
                    Value = parameter.UserName,
                };
            }
            return(result);
        }
Exemplo n.º 3
0
        public QlikApp(UserParameter parameter)
        {
            if (parameter.UseDesktop)
            {
                return;
            }

            var domainUser = new DomainUser(parameter.UserName);

            if (domainUser == null)
            {
                throw new Exception("The user must a DomainUser like this UserDirectory\\UserId");
            }

            if (!WinAuth.ValidateWinCredentials(domainUser.UserId, parameter.Password))
            {
                throw new Exception("The windows credentials was not correct.");
            }
        }