Ejemplo n.º 1
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="account">Account credential.</param>
        /// <param name="logonName">Logon name.</param>
        /// <param name="serviceName">Service name.</param>
        /// <param name="kdcIpAddress">KDC IP address</param>
        /// <param name="attributes">Client security attributes.</param>
        /// <param name="connectionType">Connection type.</param>
        public KerberosClientSecurityConfig(
            AccountCredential account,
            string serviceName,
            ClientSecurityContextAttribute attributes)
            : base(SecurityPackageType.Kerberos)
        {
            string fullDomainName = KerberosUtility.GetFullDomainName(serviceName, account.DomainName);

            this.clientCredential   = account;
            this.logonName          = account.AccountName;
            this.serviceName        = serviceName;
            this.kdcIpAddress       = fullDomainName.ParseIPAddress();
            this.securityAttributes = attributes;
            this.transportType      = TransportType.TCP;
        }
        /// <summary>
        /// Create a KerberosClientSecurityContext instance.
        /// </summary>
        /// <param name="domain" cref="KerberosClientCredential">Login user Credential</param>
        /// <param name="accountType">The type of the logon account. User or Computer</param>
        /// <param name="kdcAddress">The IP address of the KDC.</param>
        /// <param name="kdcPort">The port of the KDC.</param>
        /// <param name="transportType">Whether the transport is TCP or UDP transport.</param>
        /// <exception cref="System.ArgumentNullException">Thrown when the input parameter is null.</exception>
        public KerberosClientSecurityContext(
            string serverName,
            AccountCredential credential,
            KerberosAccountType accountType,
            string kdcAddress,
            int kdcPort,
            TransportType transportType,
            ClientSecurityContextAttribute contextAttribute,
            KerberosConstValue.OidPkt oidPkt = KerberosConstValue.OidPkt.KerberosToken,
            string salt = null
            )
        {
            string fullDomainName = KerberosUtility.GetFullDomainName(serverName, kdcAddress);

            this.credential       = credential;
            this.serverName       = serverName;
            this.contextAttribute = contextAttribute;
            this.client           = new KerberosClient(fullDomainName, this.credential.AccountName, this.credential.Password, accountType, fullDomainName, kdcPort, transportType, oidPkt, salt);
            this.UpdateDefaultSettings();
        }