/// <summary>
        /// Returns true if OrgApacheSlingDistributionPackagingImplImporterRepositoryDistriProperties instances are equal
        /// </summary>
        /// <param name="other">Instance of OrgApacheSlingDistributionPackagingImplImporterRepositoryDistriProperties to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(OrgApacheSlingDistributionPackagingImplImporterRepositoryDistriProperties other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Name == other.Name ||
                     Name != null &&
                     Name.Equals(other.Name)
                     ) &&
                 (
                     ServiceName == other.ServiceName ||
                     ServiceName != null &&
                     ServiceName.Equals(other.ServiceName)
                 ) &&
                 (
                     Path == other.Path ||
                     Path != null &&
                     Path.Equals(other.Path)
                 ) &&
                 (
                     PrivilegeName == other.PrivilegeName ||
                     PrivilegeName != null &&
                     PrivilegeName.Equals(other.PrivilegeName)
                 ));
        }
Exemple #2
0
        /// <summary>
        /// Returns true if ComAdobeGraniteDistributionCoreImplTransportAccessTokenDistribuProperties instances are equal
        /// </summary>
        /// <param name="other">Instance of ComAdobeGraniteDistributionCoreImplTransportAccessTokenDistribuProperties to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(ComAdobeGraniteDistributionCoreImplTransportAccessTokenDistribuProperties other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Name == other.Name ||
                     Name != null &&
                     Name.Equals(other.Name)
                     ) &&
                 (
                     ServiceName == other.ServiceName ||
                     ServiceName != null &&
                     ServiceName.Equals(other.ServiceName)
                 ) &&
                 (
                     UserId == other.UserId ||
                     UserId != null &&
                     UserId.Equals(other.UserId)
                 ) &&
                 (
                     AccessTokenProviderTarget == other.AccessTokenProviderTarget ||
                     AccessTokenProviderTarget != null &&
                     AccessTokenProviderTarget.Equals(other.AccessTokenProviderTarget)
                 ));
        }
        /// <summary>
        /// Returns true if ComAdobeGraniteDistributionCoreImplDiffDiffEventListenerProperties instances are equal
        /// </summary>
        /// <param name="other">Instance of ComAdobeGraniteDistributionCoreImplDiffDiffEventListenerProperties to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(ComAdobeGraniteDistributionCoreImplDiffDiffEventListenerProperties other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     DiffPath == other.DiffPath ||
                     DiffPath != null &&
                     DiffPath.Equals(other.DiffPath)
                     ) &&
                 (
                     ServiceName == other.ServiceName ||
                     ServiceName != null &&
                     ServiceName.Equals(other.ServiceName)
                 ) &&
                 (
                     ServiceUserTarget == other.ServiceUserTarget ||
                     ServiceUserTarget != null &&
                     ServiceUserTarget.Equals(other.ServiceUserTarget)
                 ));
        }
Exemple #4
0
 public override bool Equals(object obj)
 {
     return(GetHashCode() == obj.GetHashCode() &&
            obj is BeaconLocation other &&
            Address.Equals(other.Address) &&
            ServiceName.Equals(other.ServiceName));
 }
        /// <summary>
        /// Returns true if OrgApacheSlingDistributionTriggerImplPersistedJcrEventDistributiProperties instances are equal
        /// </summary>
        /// <param name="other">Instance of OrgApacheSlingDistributionTriggerImplPersistedJcrEventDistributiProperties to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(OrgApacheSlingDistributionTriggerImplPersistedJcrEventDistributiProperties other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Name == other.Name ||
                     Name != null &&
                     Name.Equals(other.Name)
                     ) &&
                 (
                     Path == other.Path ||
                     Path != null &&
                     Path.Equals(other.Path)
                 ) &&
                 (
                     ServiceName == other.ServiceName ||
                     ServiceName != null &&
                     ServiceName.Equals(other.ServiceName)
                 ) &&
                 (
                     NuggetsPath == other.NuggetsPath ||
                     NuggetsPath != null &&
                     NuggetsPath.Equals(other.NuggetsPath)
                 ));
        }
Exemple #6
0
        /// <summary>
        /// Returns true if Endpoint instances are equal
        /// </summary>
        /// <param name="other">Instance of Endpoint to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(Endpoint other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     ServiceName == other.ServiceName ||
                     ServiceName != null &&
                     ServiceName.Equals(other.ServiceName)
                     ) &&
                 (
                     Ipv4 == other.Ipv4 ||
                     Ipv4 != null &&
                     Ipv4.Equals(other.Ipv4)
                 ) &&
                 (
                     Ipv6 == other.Ipv6 ||
                     Ipv6 != null &&
                     Ipv6.Equals(other.Ipv6)
                 ) &&
                 (
                     Port == other.Port ||
                     Port != null &&
                     Port.Equals(other.Port)
                 ));
        }
Exemple #7
0
 /// <summary>Checks if the given service is the same.</summary>
 /// <param name="service">The service to check</param>
 /// <returns>True is the given service contains the same information; false if not.</returns>
 public bool Equals(Service service)
 {
     if (ServiceName.Equals(service.ServiceName) && ServiceEndpointPrefix.Equals(service.ServiceEndpointPrefix) && ServiceEndpointTemplate.Equals(service.ServiceEndpointTemplate))
     {
         return(true);
     }
     return(false);
 }
        public virtual void AfterPropertiesSet()
        {
            ReconnectOnOfflineChange = ServiceName == null || !ServiceName.Equals("SyncService");

            SyncMode = !typeof(ICommunicationObject).IsAssignableFrom(typeof(I));

            LoggingActive = true;
        }
Exemple #9
0
        /// <summary>
        /// Compares two <see cref="IrDAEndPoint"/> instances for equality.
        /// </summary>
        /// -
        /// <param name="obj">The <see cref="BluetoothEndPoint"/>
        /// to compare with the current instance.
        /// </param>
        /// -
        /// <returns><c>true</c> if <paramref name="obj"/>
        /// is a <see cref="IrDAEndPoint"/> and equal to the current instance;
        /// otherwise, <c>false</c>.
        /// </returns>
        public override bool Equals(object obj)
        {
            if (obj is IrDAEndPoint irep)
            {
                return(Address.Equals(irep.Address) && ServiceName.Equals(irep.ServiceName));
            }

            return(base.Equals(obj));
        }
Exemple #10
0
        /// <summary>
        /// Returns true if ComAdobeGraniteDistributionCoreImplDiffDiffChangesObserverProperties instances are equal
        /// </summary>
        /// <param name="other">Instance of ComAdobeGraniteDistributionCoreImplDiffDiffChangesObserverProperties to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(ComAdobeGraniteDistributionCoreImplDiffDiffChangesObserverProperties other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Enabled == other.Enabled ||
                     Enabled != null &&
                     Enabled.Equals(other.Enabled)
                     ) &&
                 (
                     AgentName == other.AgentName ||
                     AgentName != null &&
                     AgentName.Equals(other.AgentName)
                 ) &&
                 (
                     DiffPath == other.DiffPath ||
                     DiffPath != null &&
                     DiffPath.Equals(other.DiffPath)
                 ) &&
                 (
                     ObservedPath == other.ObservedPath ||
                     ObservedPath != null &&
                     ObservedPath.Equals(other.ObservedPath)
                 ) &&
                 (
                     ServiceName == other.ServiceName ||
                     ServiceName != null &&
                     ServiceName.Equals(other.ServiceName)
                 ) &&
                 (
                     PropertyNames == other.PropertyNames ||
                     PropertyNames != null &&
                     PropertyNames.Equals(other.PropertyNames)
                 ) &&
                 (
                     DistributionDelay == other.DistributionDelay ||
                     DistributionDelay != null &&
                     DistributionDelay.Equals(other.DistributionDelay)
                 ) &&
                 (
                     ServiceUserTarget == other.ServiceUserTarget ||
                     ServiceUserTarget != null &&
                     ServiceUserTarget.Equals(other.ServiceUserTarget)
                 ));
        }
Exemple #11
0
        public override bool Equals(object o)
        {
            if (o == this)
            {
                return(true);
            }

            if (!(o is ZipkinEndpoint))
            {
                return(false);
            }

            ZipkinEndpoint that = (ZipkinEndpoint)o;

            return(((ServiceName == null)
              ? (that.ServiceName == null) : ServiceName.Equals(that.ServiceName)) &&
                   ((Ipv4 == null) ? (that.Ipv4 == null) : Ipv4.Equals(that.Ipv4)) &&
                   ((Ipv6 == null) ? (that.Ipv6 == null) : Ipv6.Equals(that.Ipv6)) &&
                   Port.Equals(that.Port));
        }
        /// <summary>
        /// Returns true if ComDayCqWcmFoundationFormsImplFormChooserServletProperties instances are equal
        /// </summary>
        /// <param name="other">Instance of ComDayCqWcmFoundationFormsImplFormChooserServletProperties to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(ComDayCqWcmFoundationFormsImplFormChooserServletProperties other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     ServiceName == other.ServiceName ||
                     ServiceName != null &&
                     ServiceName.Equals(other.ServiceName)
                     ) &&
                 (
                     SlingServletResourceTypes == other.SlingServletResourceTypes ||
                     SlingServletResourceTypes != null &&
                     SlingServletResourceTypes.Equals(other.SlingServletResourceTypes)
                 ) &&
                 (
                     SlingServletSelectors == other.SlingServletSelectors ||
                     SlingServletSelectors != null &&
                     SlingServletSelectors.Equals(other.SlingServletSelectors)
                 ) &&
                 (
                     SlingServletMethods == other.SlingServletMethods ||
                     SlingServletMethods != null &&
                     SlingServletMethods.Equals(other.SlingServletMethods)
                 ) &&
                 (
                     FormsFormchooserservletAdvansesearchRequire == other.FormsFormchooserservletAdvansesearchRequire ||
                     FormsFormchooserservletAdvansesearchRequire != null &&
                     FormsFormchooserservletAdvansesearchRequire.Equals(other.FormsFormchooserservletAdvansesearchRequire)
                 ));
        }
        /// <summary>
        /// Returns true if OrgApacheSlingDistributionTriggerImplJcrEventDistributionTriggerProperties instances are equal
        /// </summary>
        /// <param name="other">Instance of OrgApacheSlingDistributionTriggerImplJcrEventDistributionTriggerProperties to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(OrgApacheSlingDistributionTriggerImplJcrEventDistributionTriggerProperties other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Name == other.Name ||
                     Name != null &&
                     Name.Equals(other.Name)
                     ) &&
                 (
                     Path == other.Path ||
                     Path != null &&
                     Path.Equals(other.Path)
                 ) &&
                 (
                     IgnoredPathsPatterns == other.IgnoredPathsPatterns ||
                     IgnoredPathsPatterns != null &&
                     IgnoredPathsPatterns.Equals(other.IgnoredPathsPatterns)
                 ) &&
                 (
                     ServiceName == other.ServiceName ||
                     ServiceName != null &&
                     ServiceName.Equals(other.ServiceName)
                 ) &&
                 (
                     Deep == other.Deep ||
                     Deep != null &&
                     Deep.Equals(other.Deep)
                 ));
        }
        /// <summary>
        /// Returns true if OrgApacheSlingDistributionAgentImplSimpleDistributionAgentFactorProperties instances are equal
        /// </summary>
        /// <param name="other">Instance of OrgApacheSlingDistributionAgentImplSimpleDistributionAgentFactorProperties to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(OrgApacheSlingDistributionAgentImplSimpleDistributionAgentFactorProperties other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Name == other.Name ||
                     Name != null &&
                     Name.Equals(other.Name)
                     ) &&
                 (
                     Title == other.Title ||
                     Title != null &&
                     Title.Equals(other.Title)
                 ) &&
                 (
                     Details == other.Details ||
                     Details != null &&
                     Details.Equals(other.Details)
                 ) &&
                 (
                     Enabled == other.Enabled ||
                     Enabled != null &&
                     Enabled.Equals(other.Enabled)
                 ) &&
                 (
                     ServiceName == other.ServiceName ||
                     ServiceName != null &&
                     ServiceName.Equals(other.ServiceName)
                 ) &&
                 (
                     LogLevel == other.LogLevel ||
                     LogLevel != null &&
                     LogLevel.Equals(other.LogLevel)
                 ) &&
                 (
                     QueueProcessingEnabled == other.QueueProcessingEnabled ||
                     QueueProcessingEnabled != null &&
                     QueueProcessingEnabled.Equals(other.QueueProcessingEnabled)
                 ) &&
                 (
                     PackageExporterTarget == other.PackageExporterTarget ||
                     PackageExporterTarget != null &&
                     PackageExporterTarget.Equals(other.PackageExporterTarget)
                 ) &&
                 (
                     PackageImporterTarget == other.PackageImporterTarget ||
                     PackageImporterTarget != null &&
                     PackageImporterTarget.Equals(other.PackageImporterTarget)
                 ) &&
                 (
                     RequestAuthorizationStrategyTarget == other.RequestAuthorizationStrategyTarget ||
                     RequestAuthorizationStrategyTarget != null &&
                     RequestAuthorizationStrategyTarget.Equals(other.RequestAuthorizationStrategyTarget)
                 ) &&
                 (
                     TriggersTarget == other.TriggersTarget ||
                     TriggersTarget != null &&
                     TriggersTarget.Equals(other.TriggersTarget)
                 ));
        }
Exemple #15
0
        /// <summary>
        /// Returns true if OrgApacheSlingDistributionAgentImplSyncDistributionAgentFactoryProperties instances are equal
        /// </summary>
        /// <param name="other">Instance of OrgApacheSlingDistributionAgentImplSyncDistributionAgentFactoryProperties to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(OrgApacheSlingDistributionAgentImplSyncDistributionAgentFactoryProperties other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Name == other.Name ||
                     Name != null &&
                     Name.Equals(other.Name)
                     ) &&
                 (
                     Title == other.Title ||
                     Title != null &&
                     Title.Equals(other.Title)
                 ) &&
                 (
                     Details == other.Details ||
                     Details != null &&
                     Details.Equals(other.Details)
                 ) &&
                 (
                     Enabled == other.Enabled ||
                     Enabled != null &&
                     Enabled.Equals(other.Enabled)
                 ) &&
                 (
                     ServiceName == other.ServiceName ||
                     ServiceName != null &&
                     ServiceName.Equals(other.ServiceName)
                 ) &&
                 (
                     LogLevel == other.LogLevel ||
                     LogLevel != null &&
                     LogLevel.Equals(other.LogLevel)
                 ) &&
                 (
                     QueueProcessingEnabled == other.QueueProcessingEnabled ||
                     QueueProcessingEnabled != null &&
                     QueueProcessingEnabled.Equals(other.QueueProcessingEnabled)
                 ) &&
                 (
                     PassiveQueues == other.PassiveQueues ||
                     PassiveQueues != null &&
                     PassiveQueues.Equals(other.PassiveQueues)
                 ) &&
                 (
                     PackageExporterEndpoints == other.PackageExporterEndpoints ||
                     PackageExporterEndpoints != null &&
                     PackageExporterEndpoints.Equals(other.PackageExporterEndpoints)
                 ) &&
                 (
                     PackageImporterEndpoints == other.PackageImporterEndpoints ||
                     PackageImporterEndpoints != null &&
                     PackageImporterEndpoints.Equals(other.PackageImporterEndpoints)
                 ) &&
                 (
                     RetryStrategy == other.RetryStrategy ||
                     RetryStrategy != null &&
                     RetryStrategy.Equals(other.RetryStrategy)
                 ) &&
                 (
                     RetryAttempts == other.RetryAttempts ||
                     RetryAttempts != null &&
                     RetryAttempts.Equals(other.RetryAttempts)
                 ) &&
                 (
                     PullItems == other.PullItems ||
                     PullItems != null &&
                     PullItems.Equals(other.PullItems)
                 ) &&
                 (
                     HttpConnTimeout == other.HttpConnTimeout ||
                     HttpConnTimeout != null &&
                     HttpConnTimeout.Equals(other.HttpConnTimeout)
                 ) &&
                 (
                     RequestAuthorizationStrategyTarget == other.RequestAuthorizationStrategyTarget ||
                     RequestAuthorizationStrategyTarget != null &&
                     RequestAuthorizationStrategyTarget.Equals(other.RequestAuthorizationStrategyTarget)
                 ) &&
                 (
                     TransportSecretProviderTarget == other.TransportSecretProviderTarget ||
                     TransportSecretProviderTarget != null &&
                     TransportSecretProviderTarget.Equals(other.TransportSecretProviderTarget)
                 ) &&
                 (
                     PackageBuilderTarget == other.PackageBuilderTarget ||
                     PackageBuilderTarget != null &&
                     PackageBuilderTarget.Equals(other.PackageBuilderTarget)
                 ) &&
                 (
                     TriggersTarget == other.TriggersTarget ||
                     TriggersTarget != null &&
                     TriggersTarget.Equals(other.TriggersTarget)
                 ));
        }
Exemple #16
0
        /// <summary>
        /// Returns true if OrgApacheSlingDistributionAgentImplForwardDistributionAgentFactoProperties instances are equal
        /// </summary>
        /// <param name="other">Instance of OrgApacheSlingDistributionAgentImplForwardDistributionAgentFactoProperties to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(OrgApacheSlingDistributionAgentImplForwardDistributionAgentFactoProperties other)
        {
            if (other is null) return false;
            if (ReferenceEquals(this, other)) return true;

            return 
                (
                    Name == other.Name ||
                    Name != null &&
                    Name.Equals(other.Name)
                ) && 
                (
                    Title == other.Title ||
                    Title != null &&
                    Title.Equals(other.Title)
                ) && 
                (
                    Details == other.Details ||
                    Details != null &&
                    Details.Equals(other.Details)
                ) && 
                (
                    Enabled == other.Enabled ||
                    Enabled != null &&
                    Enabled.Equals(other.Enabled)
                ) && 
                (
                    ServiceName == other.ServiceName ||
                    ServiceName != null &&
                    ServiceName.Equals(other.ServiceName)
                ) && 
                (
                    LogLevel == other.LogLevel ||
                    LogLevel != null &&
                    LogLevel.Equals(other.LogLevel)
                ) && 
                (
                    AllowedRoots == other.AllowedRoots ||
                    AllowedRoots != null &&
                    AllowedRoots.Equals(other.AllowedRoots)
                ) && 
                (
                    QueueProcessingEnabled == other.QueueProcessingEnabled ||
                    QueueProcessingEnabled != null &&
                    QueueProcessingEnabled.Equals(other.QueueProcessingEnabled)
                ) && 
                (
                    PackageImporterEndpoints == other.PackageImporterEndpoints ||
                    PackageImporterEndpoints != null &&
                    PackageImporterEndpoints.Equals(other.PackageImporterEndpoints)
                ) && 
                (
                    PassiveQueues == other.PassiveQueues ||
                    PassiveQueues != null &&
                    PassiveQueues.Equals(other.PassiveQueues)
                ) && 
                (
                    PriorityQueues == other.PriorityQueues ||
                    PriorityQueues != null &&
                    PriorityQueues.Equals(other.PriorityQueues)
                ) && 
                (
                    RetryStrategy == other.RetryStrategy ||
                    RetryStrategy != null &&
                    RetryStrategy.Equals(other.RetryStrategy)
                ) && 
                (
                    RetryAttempts == other.RetryAttempts ||
                    RetryAttempts != null &&
                    RetryAttempts.Equals(other.RetryAttempts)
                ) && 
                (
                    RequestAuthorizationStrategyTarget == other.RequestAuthorizationStrategyTarget ||
                    RequestAuthorizationStrategyTarget != null &&
                    RequestAuthorizationStrategyTarget.Equals(other.RequestAuthorizationStrategyTarget)
                ) && 
                (
                    TransportSecretProviderTarget == other.TransportSecretProviderTarget ||
                    TransportSecretProviderTarget != null &&
                    TransportSecretProviderTarget.Equals(other.TransportSecretProviderTarget)
                ) && 
                (
                    PackageBuilderTarget == other.PackageBuilderTarget ||
                    PackageBuilderTarget != null &&
                    PackageBuilderTarget.Equals(other.PackageBuilderTarget)
                ) && 
                (
                    TriggersTarget == other.TriggersTarget ||
                    TriggersTarget != null &&
                    TriggersTarget.Equals(other.TriggersTarget)
                ) && 
                (
                    QueueProvider == other.QueueProvider ||
                    QueueProvider != null &&
                    QueueProvider.Equals(other.QueueProvider)
                ) && 
                (
                    AsyncDelivery == other.AsyncDelivery ||
                    AsyncDelivery != null &&
                    AsyncDelivery.Equals(other.AsyncDelivery)
                ) && 
                (
                    HttpConnTimeout == other.HttpConnTimeout ||
                    HttpConnTimeout != null &&
                    HttpConnTimeout.Equals(other.HttpConnTimeout)
                );
        }
Exemple #17
0
 public bool Equals(MethodHandler other)
 {
     return(ServiceName.Equals(other.ServiceName) && MethodInfo.Name.Equals(other.MethodInfo.Name));
 }
Exemple #18
0
        public static void RegisterSpn(bool register)
        {
            IsSPNRegistered = false;
            try
            {
                var domain        = Domain.GetComputerDomain();
                var domainname    = Dns.GetHostEntry("localhost");
                var userPrincipal = GetDistinguishedName(Dns.GetHostName());
                //var userPrincipal = GetSvcDistinguishedName();
                //if (userPrincipal == null)
                //    userPrincipal = GetDistinguishedName(Dns.GetHostName());
                // Input Variable values
                string spn = string.Empty;
                if (ServiceName.Equals(MiscUtil.NOSDB_CSVC_NAME, StringComparison.CurrentCultureIgnoreCase))
                {
                    spn = GetServicePrincipalName(MiscUtil.NOSCONF_SPN, domainname.AddressList[0]); // spn name
                    //spn += (":" + ConfigurationSettings<CSHostSettings>.Current.Port);
                }
                else if (ServiceName.Equals(MiscUtil.NOSDB_DBSVC_NAME, StringComparison.CurrentCultureIgnoreCase))
                {
                    spn = GetServicePrincipalName(MiscUtil.NOSDB_SPN, domainname.AddressList[0]); // spn name
                    //spn += (":" + ConfigurationSettings<DBHostSettings>.Current.Port);
                }
                //spn += (":" + ServiceName);
                //string dn = CreateSCP(userPrincipal, spn);
                //if (ValidateSPN(spn))
                //{
                string servicePrincipalName = userPrincipal;
                //"CN=ACTUser,CN=Users,DC=SHAOLINT,DC=COM"; // DistinguishedName of the user/Computer
                string domainControllerName = domain.DomainControllers[0].Name; // Domain controller name
                string dnsDomainName        = domain.Name;                      // DNS domain name

                int    serviceClassSize = 1;
                int    serviceNameSize  = 1;
                int    instanceNameSize = 1;
                ushort port;

                StringBuilder sTemp = new StringBuilder(1);

                // Initial call to DsCrackSpn should result in BUFFER_OVERFLOW...
                uint crackSpnResult = DsCrackSpn(spn, ref serviceClassSize, sTemp, ref serviceNameSize,
                                                 sTemp, ref instanceNameSize, sTemp, out port);

                // Check for buffer overflow
                if (crackSpnResult == ERROR_BUFFER_OVERFLOW)
                {
                    // Resize our SB's
                    StringBuilder serviceClass = new StringBuilder(serviceClassSize);
                    StringBuilder serviceName  = new StringBuilder(serviceNameSize);
                    StringBuilder instanceName = new StringBuilder(instanceNameSize);

                    // Crack this spn using DsCrackSpn
                    crackSpnResult = DsCrackSpn(spn, ref serviceClassSize, serviceClass, ref serviceNameSize,
                                                serviceName, ref instanceNameSize, instanceName, out port);

                    // If Success
                    if (crackSpnResult == NO_ERROR)
                    {
                        string[] hostArray       = { instanceName.ToString() };
                        ushort[] portArray       = { port };
                        ushort   spnCount        = 1;
                        IntPtr   spnArrayPointer = new IntPtr();
                        Int32    spnArrayCount   = 0;

                        // Call to DsBind to get handle for Directory
                        System.IntPtr hDS;
                        uint          result = DsBind(domainControllerName, dnsDomainName, out hDS);

                        if (result != NO_ERROR)
                        {
                            IsSPNRegistered = false;
                            AppUtil.LogEvent("SPN is not registered. Error Code : " + result,
                                             System.Diagnostics.EventLogEntryType.Error);
                            return;
                        }

                        // Call to DsgetSpn to construct an spn
                        uint getSPNResult = DsGetSpn(DS_SPN_NAME_TYPE.DS_SPN_DN_HOST, serviceClass.ToString(),
                                                     null, port, spnCount, hostArray, portArray, ref spnArrayCount, ref spnArrayPointer);

                        if (getSPNResult == NO_ERROR)
                        {
                            if (register)
                            {
                                // Call the CSDsWriteAccountSPN for writing this spn to the object
                                uint dsWriteSpnResult = DsWriteAccountSpn(hDS, DS_SPN_WRITE_OP.DS_SPN_ADD_SPN_OP,
                                                                          servicePrincipalName, spnArrayCount, spnArrayPointer);

                                if (dsWriteSpnResult == NO_ERROR)
                                {
                                    IsSPNRegistered = true;
                                    AppUtil.LogEvent(
                                        "SPN is registered. Please check the user/Computer object for ServicePrincipalName.",
                                        System.Diagnostics.EventLogEntryType.Information);
                                    //Console.WriteLine("DsWriteAccountSpn : "+ spn + " Succeed. Please check the user/Computer object for ServicePrincipalName.");
                                    //Console.ReadKey();
                                }
                                else
                                {
                                    IsSPNRegistered = false;
                                    AppUtil.LogEvent("SPN is not registered. Error Code : " + dsWriteSpnResult,
                                                     System.Diagnostics.EventLogEntryType.Error);
                                    //Console.WriteLine("DsWriteAccountSpn Failed.");
                                    return;
                                }
                            }
                            else
                            {
                                // Call the CSDsWriteAccountSPN for writing this spn to the object
                                uint dsWriteSpnResult = DsWriteAccountSpn(hDS, DS_SPN_WRITE_OP.DS_SPN_DELETE_SPN_OP,
                                                                          servicePrincipalName, spnArrayCount, spnArrayPointer);

                                if (dsWriteSpnResult == NO_ERROR)
                                {
                                    IsSPNRegistered = false;
                                    AppUtil.LogEvent(
                                        "SPN is unregistered.",
                                        System.Diagnostics.EventLogEntryType.Information);
                                    //Console.WriteLine("DsWriteAccountSpn : "+ spn + " Succeed. Please check the user/Computer object for ServicePrincipalName.");
                                    //Console.ReadKey();
                                }
                                else
                                {
                                    IsSPNRegistered = true;
                                    AppUtil.LogEvent("SPN is not unregistered. Error Code : " + dsWriteSpnResult,
                                                     System.Diagnostics.EventLogEntryType.Error);
                                    //Console.WriteLine("DsWriteAccountSpn Failed.");
                                    return;
                                }
                            }
                        }
                        else
                        {
                            IsSPNRegistered = false;
                            AppUtil.LogEvent("SPN is not registered. Error Code : " + getSPNResult,
                                             System.Diagnostics.EventLogEntryType.Error);
                            return;
                        }
                    }
                    else
                    {
                        IsSPNRegistered = false;
                        AppUtil.LogEvent("SPN is not registered. Error Code : " + crackSpnResult,
                                         System.Diagnostics.EventLogEntryType.Error);
                        return;
                    }
                }
            }
            catch (System.DirectoryServices.ActiveDirectory.ActiveDirectoryObjectNotFoundException exc)
            {
                IsSPNRegistered = false;
                AppUtil.LogEvent("SPN is not registered. Machine is not part of Domain.",
                                 System.Diagnostics.EventLogEntryType.Information);
                return;
            }
            catch (Exception exc)
            {
                IsSPNRegistered = false;
                AppUtil.LogEvent("SPN is not registered. Machine is not part of Domain.",
                                 System.Diagnostics.EventLogEntryType.Error);
                return;
            }
        }