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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Logon Script and DN

Status
Not open for further replies.

ccoll23

MIS
Jan 17, 2002
43
0
0
US
I have a logon script that I have been using for several years that will perform funtions such as map printers and drives for a computer according to the OU it belongs to.(ex:)
Select case(OU)

'##############
'Case Ucase("Laptops")
WshNet.AddWindowsPrinterConnection "\\server\printer"


'**************
I am now working in a new domain that has many child OUs named "Laptops" and "Desktops". How can I get the script to read the DistinguishedName of the OU?


Set wshNet = CreateObject("Wscript.network")
Set WshShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Grab the user name
UserString = wshnet.UserName
WinDir = WshShell.ExpandEnvironmentStrings("%WinDir%")

'###################..GET DOMAIN OU's

Set objSysInfo = CreateObject("ADSystemInfo")
''''''''''Set objNewOU = GetObject("LDAP://DC=xx-aaadd,DC=net")
set pc = getObject("LDAP://" & objSysInfo.ComputerName)
set container = getObject(pc.parent)
OU = Mid(container.name,4)

Select case UCase(OU)
'##############
Case Ucase("Laptops")

Wscript.Echo "It's Here IN THE TRC LAPTOPS OU!"

'##############
Case Ucase("Computers")

Wscript.Echo "It's Here IN THE Computers OU!"

end select


Thanks!


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top