public static WmiDataProvider CreateWmiDataProviderForFileSearching(TargetInfo targetInfo)
        {
            var wmiNamespace = getNamespaceForTargetAddress(targetInfo.GetAddress());

            var username = string.Empty;
            var password = string.Empty;
            if (targetInfo.IsThereCredential())
            {
                username = targetInfo.credentials.GetFullyQualifiedUsername();
                password = targetInfo.credentials.GetPassword();
            }
            
            var connectionOptions = CreateConnectionOptions(username, password);

            var wmiConnectionScope = new ManagementScope(wmiNamespace, connectionOptions);
            wmiConnectionScope.Connect();

            return new WmiDataProvider(wmiConnectionScope);
        }
Exemple #2
0
        private void ConnectToTarget(TargetInfo targetInfo)
        {
            if (targetInfo.IsLocalTarget())
            {
                return;
            }

            try
            {
                string remoteUNC = string.Format(@"\\{0}", targetInfo.GetAddress());
                string userName  = targetInfo.IsThereCredential() ? targetInfo.credentials.GetFullyQualifiedUsername() : string.Empty;
                string password  = string.IsNullOrEmpty(userName) ? string.Empty : targetInfo.credentials.GetPassword();

                WinNetUtils.connectToRemote(remoteUNC, userName, password);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static WmiDataProvider CreateWmiDataProviderForFileSearching(TargetInfo targetInfo)
        {
            var wmiNamespace = getNamespaceForTargetAddress(targetInfo.GetAddress());

            var username = string.Empty;
            var password = string.Empty;

            if (targetInfo.IsThereCredential())
            {
                username = targetInfo.credentials.GetFullyQualifiedUsername();
                password = targetInfo.credentials.GetPassword();
            }

            var connectionOptions = CreateConnectionOptions(username, password);

            var wmiConnectionScope = new ManagementScope(wmiNamespace, connectionOptions);

            wmiConnectionScope.Connect();

            return(new WmiDataProvider(wmiConnectionScope));
        }
        private void ConnectToTarget(TargetInfo targetInfo)
        {
            if (targetInfo.IsLocalTarget())
                return;
            
            try
            {
                string remoteUNC = string.Format(@"\\{0}", targetInfo.GetAddress());
                string userName = targetInfo.IsThereCredential() ? targetInfo.credentials.GetFullyQualifiedUsername() : string.Empty;
                string password = string.IsNullOrEmpty(userName) ? string.Empty : targetInfo.credentials.GetPassword();

                WinNetUtils.connectToRemote(remoteUNC, userName, password);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }