This paper presents a new approach in the management of mobile ad hoc networks. Our alternative, based on mobile agent technology, allows the designing of mobile centralized servers in ad hoc network, where it is not obvious to think about a centralized management, due to the absence of any administration or fixed infrastructure in these networks. The object of this centralized approach is to provide permanent availability of services in ad hoc networks which are characterized by a distributed management. In order to evaluate the performances of the proposed approach, we apply it to solve the problem of mobile code localization in ad hoc networks. It is the matter to localize an object of double mobility, first, in relation to the mobility of its physical support in a dynamic environment, the station, and second, that of the code through the network stations.