Keeping in mind that $\text{ad}(DX)=[D,\text{ad}(X)]$, since
$$\text{ad}(DX)(Y) = [DX,Y] = D[X,Y] - [X,DY] = [D,\text{ad}(X)](Y).$$
Then
$$\lambda \text{ad}(X) = \text{ad}(D X) = [D,\text{ad}(X)] \Rightarrow \text{tr}(\text{ad} (X)) = 0. $$
Moreover,
\begin{align*}
\lambda\text{ad}(X)^{n+1} &= \left(\lambda \text{ad}(X)\right) \cdot \text{ad}(X)^{n} \\
&= [D, \text{ad}(X)] \cdot \text{ad}(X)^n\\
&= D \text{ad}(X)^{n+1} - \text{ad}(X) D \ \text{ad}(X)^n,
\end{align*}
so $\text{tr}(\text{ad}(X)^{n+1}) =0 $, $\forall$ $n $ $\in$ $\mathbb{N}$, and consequently $\text{ad}(X)$ is nilpotent, because if $\text{tr}(A^n)=0$ for all positive integers $n$, then $A$ is nilpotent.
Bonus Information
Another interesting approach is that we can, by primary decomposition theorem, write $\mathfrak{g}$ as
$$\mathfrak{g} = \mathfrak{g}_{\lambda_1}\oplus \mathfrak{g}_{\lambda_2}\oplus ...\oplus \ \mathfrak{g}_{\lambda_n}, $$
where $ \mathfrak{g}_{\lambda_i} = \{X \in \mathfrak{g};$ there exists $n\in \mathbb{N}$, such that $(D-\lambda_i I)^n X = 0 \}. $ Since $D$ is a derivation it is possible to demonstrate that
$$[\mathfrak{g}_{\lambda_i}, \mathfrak{g}_{\lambda_j}]\subset \mathfrak{g}_{\lambda_i +\lambda_j},$$
where $\mathfrak{g}_{\lambda_i +\lambda_j}=\{0\}$ if $\lambda_i +\lambda_j$ is not an eigenvalue of $D$. Therefore, for any $Y$ $\in$ $\mathfrak{g}_{\lambda_Y}$
$$\text{ad}(X)^k (Y) = [X, [X,...,[X,Y] ...] \in \mathfrak{g}_{k \lambda + \lambda_Y},$$
since, there are only a finite number of eigenvalues of $D$ and $\lambda \neq 0$, there exists some $k \in \mathbb{N}$, large enough, such that $\text{ad}(X)^k Y=0$, $\forall\ Y \in \mathfrak{g}_Y$, showing that $\text{ad}(X)$ is a nilpotent linear operator.
With a similar argumentation, we can show that if $D$ an invertible derivation, then $\text{ad}(X)$ is nilpotent for all $X\in \mathfrak{g}$ (because all eigenvalues are different from $0$, then, if $X$ $\in$ $\mathfrak{g}_{\lambda_i}$ $\Rightarrow$ $\text{ad}(X)^{k} Y$ $\in$ $\mathfrak{g}_{ k \lambda_i + \lambda_Y}$ ), and consequently, $\mathfrak{g}$ is nilpotent (Engel theorem).