Device-to-device (D2D) communication technology is widely acknowledged as an emerging candidate to alleviate the wireless traffic explosion problem for the next generation wireless local area network (WLAN) IEEE 802.11ax. In this paper, we integrate D2D communication into IEEE 802.11ax for maximizing the spectrum efficiency. Due to the spectrum scarcity, the number of available resource units (RUs) is typically less than D2D pairs and stations (STAs), which makes the management of spectrum resources more complex. To tackle this issue, we design an efficient resource management algorithm for uplink random access and resource allocation in D2D-enabled 802.11ax, which provides more channel access and resource reuse opportunities for STAs and D2D pairs. Specifically, we propose an enhanced back-off mechanism and derive the optimal contention window (CW) by a theoretical model, which improves the uplink random access efficiency. To tackle the complex interference problem in RU scheduling phase, we develop an efficient and low-complexity resource allocation algorithm based on the maximal independent set (MIS), which can schedule multiple D2D pairs to share the same RU with the specific STA. Simulation results demonstrate that the proposed algorithm significantly improves the network performance in terms of system throughput, collision rate, complete time, and channel utilization.