Ejemplo n.º 1
0
        //Remove the host from active directory
        private bool UnRegisterComputer(DataContracts.HostnameChanger msg)
        {
            Log.Entry(Name, "Removing host from domain");

            if (string.IsNullOrEmpty(msg.ADUser) || string.IsNullOrEmpty(msg.ADPass))
            {
                Log.Error(Name, "Required domain information is missing");

                // Rather than returning false right here, process with the unregistering process
                // and let the os-specific unregistering code handle bad credentials
                if (msg.ADUser == null)
                {
                    msg.ADUser = string.Empty;
                }
                if (msg.ADPass == null)
                {
                    msg.ADPass = string.Empty;
                }
            }

            try
            {
                return(_instance.UnRegisterComputer(msg));
            }
            catch (Exception ex)
            {
                Log.Error(Name, ex);
            }

            return(false);
        }