/// <summary> /// Retrieves the <see cref="NativeMethods.RASEO"/> flags for the entry specified. /// </summary> /// <param name="entry">The entry whose options to retrieve.</param> /// <returns>The <see cref="NativeMethods.RASEO"/> flags.</returns> /// <exception cref="System.ArgumentNullException"><paramref name="entry"/> is a null reference (<b>Nothing</b> in Visual Basic).</exception> public static NativeMethods.RASEO GetRasEntryOptions(RasEntry entry) { NativeMethods.RASEO options = NativeMethods.RASEO.None; if (entry != null) { options |= (NativeMethods.RASEO)Utilities.SetFlag(entry.Options.UseCountryAndAreaCodes, NativeMethods.RASEO.UseCountryAndAreaCodes); options |= (NativeMethods.RASEO)Utilities.SetFlag(!Utilities.IsIPAddressNullOrAnyAddress(entry.IPAddress), NativeMethods.RASEO.SpecificIPAddress); options |= (NativeMethods.RASEO)Utilities.SetFlag(!Utilities.IsIPAddressNullOrAnyAddress(entry.DnsAddress) || !Utilities.IsIPAddressNullOrAnyAddress(entry.DnsAddressAlt) || !Utilities.IsIPAddressNullOrAnyAddress(entry.WinsAddress) || !Utilities.IsIPAddressNullOrAnyAddress(entry.WinsAddressAlt), NativeMethods.RASEO.SpecificNameServers); options |= (NativeMethods.RASEO)Utilities.SetFlag(entry.Options.IPHeaderCompression, NativeMethods.RASEO.IPHeaderCompression); options |= (NativeMethods.RASEO)Utilities.SetFlag(entry.Options.RemoteDefaultGateway, NativeMethods.RASEO.RemoteDefaultGateway); options |= (NativeMethods.RASEO)Utilities.SetFlag(entry.Options.DisableLcpExtensions, NativeMethods.RASEO.DisableLcpExtensions); options |= (NativeMethods.RASEO)Utilities.SetFlag(entry.Options.TerminalBeforeDial, NativeMethods.RASEO.TerminalBeforeDial); options |= (NativeMethods.RASEO)Utilities.SetFlag(entry.Options.TerminalAfterDial, NativeMethods.RASEO.TerminalAfterDial); options |= (NativeMethods.RASEO)Utilities.SetFlag(entry.Options.ModemLights, NativeMethods.RASEO.ModemLights); options |= (NativeMethods.RASEO)Utilities.SetFlag(entry.Options.SoftwareCompression, NativeMethods.RASEO.SoftwareCompression); options |= (NativeMethods.RASEO)Utilities.SetFlag(entry.Options.RequireEncryptedPassword, NativeMethods.RASEO.RequireEncryptedPassword); options |= (NativeMethods.RASEO)Utilities.SetFlag(entry.Options.RequireMSEncryptedPassword, NativeMethods.RASEO.RequireMSEncryptedPassword); options |= (NativeMethods.RASEO)Utilities.SetFlag(entry.Options.RequireDataEncryption, NativeMethods.RASEO.RequireDataEncryption); options |= (NativeMethods.RASEO)Utilities.SetFlag(entry.Options.NetworkLogOn, NativeMethods.RASEO.NetworkLogOn); options |= (NativeMethods.RASEO)Utilities.SetFlag(entry.Options.UseLogOnCredentials, NativeMethods.RASEO.UseLogOnCredentials); options |= (NativeMethods.RASEO)Utilities.SetFlag(entry.Options.PromoteAlternates, NativeMethods.RASEO.PromoteAlternates); options |= (NativeMethods.RASEO)Utilities.SetFlag(entry.Options.SecureLocalFiles, NativeMethods.RASEO.SecureLocalFiles); options |= (NativeMethods.RASEO)Utilities.SetFlag(entry.Options.RequireEap, NativeMethods.RASEO.RequireEap); options |= (NativeMethods.RASEO)Utilities.SetFlag(entry.Options.RequirePap, NativeMethods.RASEO.RequirePap); options |= (NativeMethods.RASEO)Utilities.SetFlag(entry.Options.RequireSpap, NativeMethods.RASEO.RequireSpap); options |= (NativeMethods.RASEO)Utilities.SetFlag(entry.Options.CustomEncryption, NativeMethods.RASEO.Custom); options |= (NativeMethods.RASEO)Utilities.SetFlag(entry.Options.PreviewPhoneNumber, NativeMethods.RASEO.PreviewPhoneNumber); options |= (NativeMethods.RASEO)Utilities.SetFlag(entry.Options.SharedPhoneNumbers, NativeMethods.RASEO.SharedPhoneNumbers); options |= (NativeMethods.RASEO)Utilities.SetFlag(entry.Options.PreviewUserPassword, NativeMethods.RASEO.PreviewUserPassword); options |= (NativeMethods.RASEO)Utilities.SetFlag(entry.Options.PreviewDomain, NativeMethods.RASEO.PreviewDomain); options |= (NativeMethods.RASEO)Utilities.SetFlag(entry.Options.ShowDialingProgress, NativeMethods.RASEO.ShowDialingProgress); options |= (NativeMethods.RASEO)Utilities.SetFlag(entry.Options.RequireChap, NativeMethods.RASEO.RequireChap); options |= (NativeMethods.RASEO)Utilities.SetFlag(entry.Options.RequireMSChap, NativeMethods.RASEO.RequireMSChap); options |= (NativeMethods.RASEO)Utilities.SetFlag(entry.Options.RequireMSChap2, NativeMethods.RASEO.RequireMSChap2); options |= (NativeMethods.RASEO)Utilities.SetFlag(entry.Options.RequireWin95MSChap, NativeMethods.RASEO.RequireWin95MSChap); options |= (NativeMethods.RASEO)Utilities.SetFlag(entry.Options.CustomScript, NativeMethods.RASEO.CustomScript); } return(options); }
/// <summary> /// Sets the 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> public static void SetRasEntryOptions(RasEntry entry, NativeMethods.RASEO value) { if (entry != null) { RasEntryOptions options = entry.Options; options.UseCountryAndAreaCodes = Utilities.HasFlag(value, NativeMethods.RASEO.UseCountryAndAreaCodes); options.IPHeaderCompression = Utilities.HasFlag(value, NativeMethods.RASEO.IPHeaderCompression); options.RemoteDefaultGateway = Utilities.HasFlag(value, NativeMethods.RASEO.RemoteDefaultGateway); options.DisableLcpExtensions = Utilities.HasFlag(value, NativeMethods.RASEO.DisableLcpExtensions); options.TerminalBeforeDial = Utilities.HasFlag(value, NativeMethods.RASEO.TerminalBeforeDial); options.TerminalAfterDial = Utilities.HasFlag(value, NativeMethods.RASEO.TerminalAfterDial); options.ModemLights = Utilities.HasFlag(value, NativeMethods.RASEO.ModemLights); options.SoftwareCompression = Utilities.HasFlag(value, NativeMethods.RASEO.SoftwareCompression); options.RequireEncryptedPassword = Utilities.HasFlag(value, NativeMethods.RASEO.RequireEncryptedPassword); options.RequireMSEncryptedPassword = Utilities.HasFlag(value, NativeMethods.RASEO.RequireMSEncryptedPassword); options.RequireDataEncryption = Utilities.HasFlag(value, NativeMethods.RASEO.RequireDataEncryption); options.NetworkLogOn = Utilities.HasFlag(value, NativeMethods.RASEO.NetworkLogOn); options.UseLogOnCredentials = Utilities.HasFlag(value, NativeMethods.RASEO.UseLogOnCredentials); options.PromoteAlternates = Utilities.HasFlag(value, NativeMethods.RASEO.PromoteAlternates); options.SecureLocalFiles = Utilities.HasFlag(value, NativeMethods.RASEO.SecureLocalFiles); options.RequireEap = Utilities.HasFlag(value, NativeMethods.RASEO.RequireEap); options.RequirePap = Utilities.HasFlag(value, NativeMethods.RASEO.RequirePap); options.RequireSpap = Utilities.HasFlag(value, NativeMethods.RASEO.RequireSpap); options.CustomEncryption = Utilities.HasFlag(value, NativeMethods.RASEO.Custom); options.PreviewPhoneNumber = Utilities.HasFlag(value, NativeMethods.RASEO.PreviewPhoneNumber); options.SharedPhoneNumbers = Utilities.HasFlag(value, NativeMethods.RASEO.SharedPhoneNumbers); options.PreviewUserPassword = Utilities.HasFlag(value, NativeMethods.RASEO.PreviewUserPassword); options.PreviewDomain = Utilities.HasFlag(value, NativeMethods.RASEO.PreviewDomain); options.ShowDialingProgress = Utilities.HasFlag(value, NativeMethods.RASEO.ShowDialingProgress); options.RequireChap = Utilities.HasFlag(value, NativeMethods.RASEO.RequireChap); options.RequireMSChap = Utilities.HasFlag(value, NativeMethods.RASEO.RequireMSChap); options.RequireMSChap2 = Utilities.HasFlag(value, NativeMethods.RASEO.RequireMSChap2); options.RequireWin95MSChap = Utilities.HasFlag(value, NativeMethods.RASEO.RequireWin95MSChap); options.CustomScript = Utilities.HasFlag(value, NativeMethods.RASEO.CustomScript); } }