Using DSADD to add users automatically

G

Guest

I am trying to create a module to use with DSADD.exe, the command line method
of creating new network users in Active Directory. I know the syntax for
DSADD and can use it successfully on the command line manually. But when I
try to use it through a module in Access it does not work. I think the
problem has to do with the quote marks needed around the Distinguished name
argument for DSADD. I use shell to run Windows\system32\dsadd.exe and that
requires quotes so when I get to the username argument I am using single
quotes. But I need to use double quotes. Does this make any sense?
 
D

Douglas J. Steele

Post the code you're trying to use.

I'm guessing you're got something like ", ... 'Distinguished Name', ..."

If that's the case, try ", ... ""Distinguished Name"", ..."

In other words, replace each single quote with two double quotes.
 
G

Guest

For future reference, this works:

Shell ("c:\windows\system32\dsadd.exe user """ & "CN=" & LastName & "\, " &
FullFirstName & ",OU=XXXX Users,DC=XXXX,DC=com""" & " -samid " & Logon & "
-pwd XXXXXX -fn " & Firstname & " -mi " & MI & " -ln " & LastName)

Not sure why exactly, but I kept fooling around with it until it worked.
There are many other arguments possible, but this gets the ball rolling.
Thanks for your time and help.
 
K

Kevin K. Sullivan

In the future, don't be shy to take a look at the text you're passing by
stuffing it in a local variable and printing it to the debug window. This
allows you build up the command over several lines through string
concatenation (not to mention including comments!):
--------
Dim strCommand as String ' variable to hold the string passed to Shell

strCommand = "c:\windows\system32\dsadd.exe user " ' name of the program
strCommand = strCommand & """CN=" & LastName & "\, " & FullFirstName 'Must
include double quotes
strCommand = strCommand & ",OU=XXXX Users,DC=XXXX,DC=com""" & " -samid " &
Logon ' more comments here, etc.
strCommand = strCommand & " -pwd XXXXXX -fn " & Firstname & " -mi " & MI &
" -ln " & LastName)

'send the whole thing to the debug window to eyeball it
Debug.Print strCommand

Shell strCommand
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top