Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get Domain User Info

Status
Not open for further replies.

sunny456

Programmer
Nov 7, 2002
21
0
0
US
I need a way to load all my domain user names into a table. The following script does basically want I want but I need to convert this into a stored procedure and NOT encode the username and password.

Thanks for your help in advance,

Sunny




Option Explicit

Dim sDomain
Dim oDomain
Dim sFilter
Dim oADobject
Dim MyConnection
Dim MyCommand

sDomain = "MyDomain"
sFilter = "User"

'Connect to domain
Set oDomain = GetObject("WinNT://" & sDomain)
oDomain.Filter = Array( sFilter )

Set MyConnection = CreateObject("ADODB.Connection")
'SQL Connection String
MyConnection.Open "Driver={SQL Server};server=(local);database=Employees;uid=myname;pwd=mypassword;"

Set MyCommand = CreateObject("ADODB.Command")
Set MyCommand.ActiveConnection = MyConnection
MyCommand.CommandText = "INSERT INTO [Employee] ([Username], [FullName], [Description]) VALUES(?,?,?)"
MyCommand.CommandType = 1

For Each oADobject In oDomain
MyCommand.Parameters(0).Value = oADobject.Name
MyCommand.Parameters(1).Value = oADobject.FullName
MyCommand.Parameters(2).Value = oADobject.Description
MyCommand.Execute
Next

MyConnection.Close()
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top