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

Create Security Object on Remote Server

Status
Not open for further replies.

LuckyDuck528

Programmer
Dec 21, 2004
65
US
Hello-
I normally ask for help in the VBScript forum but I think this might be a better place for this question. Please let me know if you know of a better place to ask it...

I created a Master script that runs on my PC. It maps drives to different servers and runs another script (also from my PC) on the server.

Part of what the second script does is to find a particular folder, get the security group names and then get the names of all of the users that belong to that group.

The program works perfectly until it has to Get the security object. Since the program works fine if it is being run on the actual server itself.

I guess I need to know if anyone thinks it is possible to have it somehow say "go to mapped drive S: and get this security for this path"... any ideas on how to fix this would be appreciated! If you need more code or information let me know!

Thanks for your time! I sincerely appreciate it! [smile]


Code:
Function FindUsers(SubFolder)
[COLOR=green]
	Wscript.Echo SubFolder.Path
       'I put this in to check that it's looking for the 
       'right folder, which it is.
[/color]	
	Set RootDSE = GetObject("LDAP://rootDSE")
	Domain = RootDSE.Get("DefaultNamingContext")
	          
	Set ObjConnection = CreateObject("ADODB.Connection")
	ObjConnection.Open "Provider=ADsDSOObject;"

	Set ObjCommand = CreateObject("ADODB.Command")
	ObjCommand.ActiveConnection = ObjConnection
[COLOR=red]
	Set ObjSecurity = GetObject("winmgmts:\\" & ServerName & "\root\cimv2:Win32_LogicalFileSecuritySetting='" & SubFolder.Path & "'")
[/color]
	ObjSecurity.GetSecurityDescriptor ObjSD
	Set ObjOwner = ObjSD.Owner

	For Each ObjACE In ObjSD.DACL	
		Permissions = "Special"
		If ObjACE.AccessMask = 2032127 Then Permissions = "Full"
 
For the record... The code above was adapted from a script I found on the web.. it's documented at the end of my program... Sorry, I always like to include that sort of thing when posting!

Thanks!

'******************************"
'* Script: EnumFolderPerms.vbs"
'* Creation Date: 6-17-2003"
'* Author: Ron Rosenkoetter
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top