I need to change users passwords in Active Directory using the dsmod command at the command line. I have that part working, but I have a problem. Here is the DSmod portion :
Dim ProcessArgument As String
ProcessArgument = "User ""cn=" + Convert.ToString(UserName).Trim + ",ou=place,ou=Users,ou=MainName, dc=Domain, dc=org"" -pwd " + UnEncryptPassword.Trim
Dim MyProcess As New System.Diagnostics.Process
MyProcess.StartInfo.CreateNoWindow = True
MyProcess.StartInfo.UseShellExecute = True
MyProcess.StartInfo.WorkingDirectory = "C:\Windows\system32"
MyProcess.StartInfo.FileName = "dsmod.exe"
MyProcess.StartInfo.Arguments = ProcessArgument
MyProcess.Start()
The problem is that the ou=place can be different for each employee. I am trying to use dsquery to retreive that information. The command runs, but I am unable to capture the result back to the program. Here is the snip I am using for the dsquery :
Dim ProcessArgument2 As String
ProcessArgument2 = " User -samid " + Convert.ToString(UserName).Trim + " >> c:\usertest.txt "
Dim MyProcess2 As New System.Diagnostics.Process
MyProcess2.StartInfo.CreateNoWindow = True
MyProcess2.StartInfo.UseShellExecute = True
MyProcess2.StartInfo.WorkingDirectory = "C:\Windows\system32"
MyProcess2.StartInfo.FileName = "dsquery"
MyProcess2.StartInfo.Arguments = ProcessArgument2
MyProcess2.StartInfo.RedirectStandardOutput = True
MyProcess2.Start()
Any ideas would be helpful.
- Jason
Dim ProcessArgument As String
ProcessArgument = "User ""cn=" + Convert.ToString(UserName).Trim + ",ou=place,ou=Users,ou=MainName, dc=Domain, dc=org"" -pwd " + UnEncryptPassword.Trim
Dim MyProcess As New System.Diagnostics.Process
MyProcess.StartInfo.CreateNoWindow = True
MyProcess.StartInfo.UseShellExecute = True
MyProcess.StartInfo.WorkingDirectory = "C:\Windows\system32"
MyProcess.StartInfo.FileName = "dsmod.exe"
MyProcess.StartInfo.Arguments = ProcessArgument
MyProcess.Start()
The problem is that the ou=place can be different for each employee. I am trying to use dsquery to retreive that information. The command runs, but I am unable to capture the result back to the program. Here is the snip I am using for the dsquery :
Dim ProcessArgument2 As String
ProcessArgument2 = " User -samid " + Convert.ToString(UserName).Trim + " >> c:\usertest.txt "
Dim MyProcess2 As New System.Diagnostics.Process
MyProcess2.StartInfo.CreateNoWindow = True
MyProcess2.StartInfo.UseShellExecute = True
MyProcess2.StartInfo.WorkingDirectory = "C:\Windows\system32"
MyProcess2.StartInfo.FileName = "dsquery"
MyProcess2.StartInfo.Arguments = ProcessArgument2
MyProcess2.StartInfo.RedirectStandardOutput = True
MyProcess2.Start()
Any ideas would be helpful.
- Jason