(An alternative to my answer). Programs that expect user interaction on /dev/tty rather than just reading stdin can be handled with the expect command, which uses the tcl language. For example, assuming you have expect in /usr/bin/expect, create a file setuserpw holding this:
#!/usr/bin/expect -f expect_user -re "(\[^ \]+) (\[^ \]+)\n" set user $expect_out(1,string) set pw $expect_out(2,string) spawn passwd $user expect "password:" send "$pw\r" expect "password:" send "$pw\r" expect eof
and dont forget to make it executable
chmod +x ./setuserpw
The script reads stdin for two words on a line, and sets variables user and pw to these. It then runs (spawn) the passwd program for the user, connecting via a pseudo tty (see man pty). It reads its output for a prompt matching "password:". It then sends the password to the program, and does the same again (assuming the program asks you for the password twice). For example:
./setuserpw <<! user1 passwd1 !
In your case, replace passwd by slappasswd, and verify the prompts you get correspond to those in this example.