This paper proposes a novel bidirectional optimization of buildings integrated to the smart distribution grid, which possess potential benefits to the customers and utilities both. Mathematical models required for the optimal operations of buildings and grids are developed and a new method is proposed to obtain the solution of the bidirectional optimization. In this work, minimization of the cost of energy is chosen as an objective for the building load management, while the distribution utilities aim to increase load penetration by maximizing the load factor. Case studies are carried out based on actual data collected from an office building at Michigan Technological University, and using a standard distribution test feeder. Studies demonstrate that the proposed bidirectional optimization is beneficial to both the customer and the distribution grid as it shows significant saving in the energy costs and improvement on the system load factor.