コード例 #1
0
        /// <summary>
        /// Retrieves the <see cref="NativeMethods.RASEO2"/> flags for the entry specified.
        /// </summary>
        /// <param name="entry">The entry whose options to retrieve.</param>
        /// <returns>The <see cref="NativeMethods.RASEO2"/> flags.</returns>
        /// <exception cref="System.ArgumentNullException"><paramref name="entry"/> is a null reference (<b>Nothing</b> in Visual Basic).</exception>
        public static NativeMethods.RASEO2 GetRasEntryExtendedOptions(RasEntry entry)
        {
            if (entry == null)
            {
                ThrowHelper.ThrowArgumentNullException("entry");
            }

            NativeMethods.RASEO2 options = NativeMethods.RASEO2.None;

            options |= (NativeMethods.RASEO2)Utilities.SetFlag(entry.Options.SecureFileAndPrint, NativeMethods.RASEO2.SecureFileAndPrint);
            options |= (NativeMethods.RASEO2)Utilities.SetFlag(entry.Options.SecureClientForMSNet, NativeMethods.RASEO2.SecureClientForMSNet);
            options |= (NativeMethods.RASEO2)Utilities.SetFlag(entry.Options.DoNotNegotiateMultilink, NativeMethods.RASEO2.DoNotNegotiateMultilink);
            options |= (NativeMethods.RASEO2)Utilities.SetFlag(entry.Options.DoNotUseRasCredentials, NativeMethods.RASEO2.DoNotUseRasCredentials);
            options |= (NativeMethods.RASEO2)Utilities.SetFlag(entry.Options.UsePreSharedKey, NativeMethods.RASEO2.UsePreSharedKey);
            options |= (NativeMethods.RASEO2)Utilities.SetFlag(entry.Options.Internet, NativeMethods.RASEO2.Internet);
            options |= (NativeMethods.RASEO2)Utilities.SetFlag(entry.Options.DisableNbtOverIP, NativeMethods.RASEO2.DisableNbtOverIP);
            options |= (NativeMethods.RASEO2)Utilities.SetFlag(entry.Options.UseGlobalDeviceSettings, NativeMethods.RASEO2.UseGlobalDeviceSettings);
            options |= (NativeMethods.RASEO2)Utilities.SetFlag(entry.Options.ReconnectIfDropped, NativeMethods.RASEO2.ReconnectIfDropped);
            options |= (NativeMethods.RASEO2)Utilities.SetFlag(entry.Options.SharePhoneNumbers, NativeMethods.RASEO2.SharePhoneNumbers);

#if (WIN2K8 || WIN7 || WIN8)
            options |= (NativeMethods.RASEO2)Utilities.SetFlag(entry.Options.SecureRoutingCompartment, NativeMethods.RASEO2.SecureRoutingCompartment);
            options |= (NativeMethods.RASEO2)Utilities.SetFlag(entry.Options.UseTypicalSettings, NativeMethods.RASEO2.UseTypicalSettings);
            options |= (NativeMethods.RASEO2)Utilities.SetFlag(!Utilities.IsIPAddressNullOrAnyAddress(entry.IPv6DnsAddress) || !Utilities.IsIPAddressNullOrAnyAddress(entry.IPv6DnsAddressAlt), NativeMethods.RASEO2.IPv6SpecificNameServer);
            options |= (NativeMethods.RASEO2)Utilities.SetFlag(entry.Options.IPv6RemoteDefaultGateway, NativeMethods.RASEO2.IPv6RemoteDefaultGateway);
            options |= (NativeMethods.RASEO2)Utilities.SetFlag(entry.Options.RegisterIPWithDns, NativeMethods.RASEO2.RegisterIPWithDns);
            options |= (NativeMethods.RASEO2)Utilities.SetFlag(entry.Options.UseDnsSuffixForRegistration, NativeMethods.RASEO2.UseDnsSuffixForRegistration);
            options |= (NativeMethods.RASEO2)Utilities.SetFlag(entry.IPv4InterfaceMetric != 0, NativeMethods.RASEO2.IPv4ExplicitMetric);
            options |= (NativeMethods.RASEO2)Utilities.SetFlag(entry.IPv6InterfaceMetric != 0, NativeMethods.RASEO2.IPv6ExplicitMetric);
            options |= (NativeMethods.RASEO2)Utilities.SetFlag(entry.Options.DisableIkeNameEkuCheck, NativeMethods.RASEO2.DisableIkeNameEkuCheck);
#endif
#if (WIN7 || WIN8)
            options |= (NativeMethods.RASEO2)Utilities.SetFlag(entry.Options.DisableClassBasedStaticRoute, NativeMethods.RASEO2.DisableClassBasedStaticRoute);
            options |= (NativeMethods.RASEO2)Utilities.SetFlag(!Utilities.IsIPAddressNullOrAnyAddress(entry.IPv6Address), NativeMethods.RASEO2.IPv6SpecificAddress);
            options |= (NativeMethods.RASEO2)Utilities.SetFlag(entry.Options.DisableMobility, NativeMethods.RASEO2.DisableMobility);
            options |= (NativeMethods.RASEO2)Utilities.SetFlag(entry.Options.RequireMachineCertificates, NativeMethods.RASEO2.RequireMachineCertificates);
#endif
#if (WIN8)
            options |= (NativeMethods.RASEO2)Utilities.SetFlag(entry.Options.UsePreSharedKeyForIkeV2Initiator, NativeMethods.RASEO2.UsePreSharedKeyForIkev2Initiator);
            options |= (NativeMethods.RASEO2)Utilities.SetFlag(entry.Options.UsePreSharedKeyForIkeV2Responder, NativeMethods.RASEO2.UsePreSharedKeyForIkev2Responder);
            options |= (NativeMethods.RASEO2)Utilities.SetFlag(entry.Options.CacheCredentials, NativeMethods.RASEO2.CacheCredentials);
#endif

            return(options);
        }
コード例 #2
0
        /// <summary>
        /// Sets the extended options on a <see cref="RasEntry"/> for the flags specified.
        /// </summary>
        /// <param name="entry">The entry whose options to set.</param>
        /// <param name="value">The flags of the entry.</param>
        /// <exception cref="System.ArgumentNullException"><paramref name="entry"/> is a null reference (<b>Nothing</b> in Visual Basic).</exception>
        public static void SetRasEntryExtendedOptions(RasEntry entry, NativeMethods.RASEO2 value)
        {
            if (entry == null)
            {
                ThrowHelper.ThrowArgumentNullException("entry");
            }

            RasEntryOptions options = entry.Options;

            options.SecureFileAndPrint      = Utilities.HasFlag(value, NativeMethods.RASEO2.SecureFileAndPrint);
            options.SecureClientForMSNet    = Utilities.HasFlag(value, NativeMethods.RASEO2.SecureClientForMSNet);
            options.DoNotNegotiateMultilink = Utilities.HasFlag(value, NativeMethods.RASEO2.DoNotNegotiateMultilink);
            options.DoNotUseRasCredentials  = Utilities.HasFlag(value, NativeMethods.RASEO2.DoNotUseRasCredentials);
            options.UsePreSharedKey         = Utilities.HasFlag(value, NativeMethods.RASEO2.UsePreSharedKey);
            options.Internet                = Utilities.HasFlag(value, NativeMethods.RASEO2.Internet);
            options.DisableNbtOverIP        = Utilities.HasFlag(value, NativeMethods.RASEO2.DisableNbtOverIP);
            options.UseGlobalDeviceSettings = Utilities.HasFlag(value, NativeMethods.RASEO2.UseGlobalDeviceSettings);
            options.ReconnectIfDropped      = Utilities.HasFlag(value, NativeMethods.RASEO2.ReconnectIfDropped);
            options.SharePhoneNumbers       = Utilities.HasFlag(value, NativeMethods.RASEO2.SharePhoneNumbers);

#if (WIN2K8 || WIN7 || WIN8)
            options.SecureRoutingCompartment    = Utilities.HasFlag(value, NativeMethods.RASEO2.SecureRoutingCompartment);
            options.UseTypicalSettings          = Utilities.HasFlag(value, NativeMethods.RASEO2.UseTypicalSettings);
            options.IPv6RemoteDefaultGateway    = Utilities.HasFlag(value, NativeMethods.RASEO2.IPv6RemoteDefaultGateway);
            options.RegisterIPWithDns           = Utilities.HasFlag(value, NativeMethods.RASEO2.RegisterIPWithDns);
            options.UseDnsSuffixForRegistration = Utilities.HasFlag(value, NativeMethods.RASEO2.UseDnsSuffixForRegistration);
            options.DisableIkeNameEkuCheck      = Utilities.HasFlag(value, NativeMethods.RASEO2.DisableIkeNameEkuCheck);
#endif
#if (WIN7 || WIN8)
            options.DisableClassBasedStaticRoute = Utilities.HasFlag(value, NativeMethods.RASEO2.DisableClassBasedStaticRoute);
            options.DisableMobility            = Utilities.HasFlag(value, NativeMethods.RASEO2.DisableMobility);
            options.RequireMachineCertificates = Utilities.HasFlag(value, NativeMethods.RASEO2.RequireMachineCertificates);
#endif
#if (WIN8)
            options.UsePreSharedKeyForIkeV2Initiator = Utilities.HasFlag(value, NativeMethods.RASEO2.UsePreSharedKeyForIkev2Initiator);
            options.UsePreSharedKeyForIkeV2Responder = Utilities.HasFlag(value, NativeMethods.RASEO2.UsePreSharedKeyForIkev2Responder);
            options.CacheCredentials = Utilities.HasFlag(value, NativeMethods.RASEO2.CacheCredentials);
#endif
        }