Beispiel #1
0
        private void connect()
        {
            // Validate 0 < port < 65536
            if (Options.Port < 1 || Options.Port > 65535)
            {
                throw new ArgumentOutOfRangeException("port", Options.Port,
                    "SAS metadata server port number must be in the range 1...65535.");
            }

            // Get an object factory and make a connection to the SAS metadata server connection.
            if (Options.Verbose)
            {
                Console.WriteLine("Attempting to connect to SAS metadata server {0}:{1} as user '{2}'.",
                    Options.Host, Options.Port, Options.User);
            }

            Login login;
            // TODO: support IWA with new option that leaves login as null.
            login = new Login(Options.User, Options.Password, Options.AuthDomain);
            try
            {
                userContext = new UserContext();
                userContext.SetOmrCredentials(login, Options.Host, Options.Port);
                Repository repository = userContext.GetRepository();
                iomi = (SASOMI.IOMI)repository.IOmi;
                if (Options.Verbose)
                {
                    Console.WriteLine("Successfully connected to SAS metadata server as '{0}' ({1})",
                        userContext.GetUserName(), userContext.ResolvedIdentity);
                }
            }
            catch (UserContextException)
            {
                // Log the connection failure and rethrow (to be handled higher up).
                Console.WriteLine("ERROR: Failed to connect to the SAS metadata server.");
                throw;
            }
        }