Beispiel #1
0
        public void ConvertToDynamicLease(HttpListenerRequest request)
        {
            string scopeName = request.QueryString["name"];

            if (string.IsNullOrEmpty(scopeName))
            {
                throw new DnsWebServiceException("Parameter 'name' missing.");
            }

            Scope scope = _dnsWebService.DhcpServer.GetScope(scopeName);

            if (scope == null)
            {
                throw new DnsWebServiceException("DHCP scope does not exists: " + scopeName);
            }

            string strClientIdentifier = request.QueryString["clientIdentifier"];
            string strHardwareAddress  = request.QueryString["hardwareAddress"];

            if (!string.IsNullOrEmpty(strClientIdentifier))
            {
                scope.ConvertToDynamicLease(ClientIdentifierOption.Parse(strClientIdentifier));
            }
            else if (!string.IsNullOrEmpty(strHardwareAddress))
            {
                scope.ConvertToDynamicLease(strHardwareAddress);
            }
            else
            {
                throw new DnsWebServiceException("Parameter 'hardwareAddress' or 'clientIdentifier' missing. At least one of them must be specified.");
            }

            _dnsWebService.DhcpServer.SaveScope(scopeName);

            _dnsWebService.Log.Write(DnsWebService.GetRequestRemoteEndPoint(request), "[" + _dnsWebService.GetSession(request).Username + "] DHCP scope's lease was unreserved successfully: " + scopeName);
        }