NT users integration (again)

Bosinius, Tim tim.bosinius at gkd-rso.de
Wed Jun 23 13:04:56 GMT 1999


A couple of days ago Anders Östling (anders.ostling at neurope.ikea.com)
presented a way to sync NT users to samba. He stated that he used
an eval version of XLNT from www.advsyscon.com and he did not find the
script
he used.

I created a script that does the same using the Windows Scripting Host (WSH)
and the Active Directory Service Interfaces (ADSI) 2.5, which are both
downloadable
from Microsoft for free.

Make sure to change the computer name and the admin account Information.
You can also specify another output file.
It takes some seconds before the file is created  - so be patient when you
execute the script.

It is also possible to create (NT) users with VBscript and ADSI,
so a two-way sync could be build. I use this script to get all accounts
from our PDC and add the users to the /etc/passwd on our linux / samba
domain members.


Tim Bosinius

---cut here---
Dim WshShell, WshNetwork, objFS
Dim sComputer
Dim sName
Dim sPassword
Dim sOutputFile
Dim F1
Dim o
Dim cont
Dim usr


On Error Resume Next
Set WshShell = WScript.CreateObject("WScript.Shell")
Set WSHNetwork = WScript.CreateObject("WScript.Network")
set objFS = Wscript.CreateObject ("Scripting.FileSystemObject")
Const ForWriting = 2

sComputer = "yourcomputer"
sName = "admin account"
sPassword = "admin pass"
sOutputFile = "c:\temp\user.txt"

 call main()

WScript.Quit 'Exit

Sub Main()
' Main execution code
On Error Resume Next
Set o = GetObject("WinNT:")
Set cont = o.OpenDSObject("WinNT://" & sComputer, sName, sPassword, 1)
cont.Filter = Array("user")

' Now write the stuff to a file
F1 = FreeFile

Set objReport = objFS.OpenTextFile(sOutputFile, ForWriting, True)
If Err.Number <> 0 Then
 Wscript.Echo "Error creating report file"
 Wscript.Quit
End If

for each usr in cont
'CRLF at the end
'objReport.Writeline usr.Name & " - " & usr.Fullname

'LF at the end
objReport.Write usr.Name & " - " & usr.Fullname & vbLF
next

set objFS = Nothing
Set usr = Nothing
Set cont = Nothing
Set o = Nothing

End Sub




More information about the samba-ntdom mailing list