IMHO.WS

IMHO.WS (http://www.imho.ws/index.php)
-   Программирование (http://www.imho.ws/forumdisplay.php?f=40)
-   -   Права юзера для доступа к локальной папке на VBScript (http://www.imho.ws/showthread.php?t=99295)

SabbaOff 31.01.2006 18:08

Права юзера для доступа к локальной папке на VBScript
 
Подскажите, плз как на скрипте разрешить доступ юзеру к папке (не шара!)?..
Пример:

Код:

Dim FSO, TheFile, Line, objFSO, objFolder
set FSO=CreateObject("Scripting.FileSystemObject")
set obj=GetObject("LDAP://cn=users,dc=domen,dc=com")
set TheFile= FSO.OpenTextFile("users.txt")
Set objFSO = CreateObject("Scripting.FileSystemObject")

Do while NOT TheFile.AtEndOfStream
Line=TheFile.ReadLine
set usr=obj.Create("user", Line)
usr.SetInfo

usr.setpassword="123456"
usr.SetInfo

Set objFolder = objFSO.CreateFolder("C:\" & Line)

'И вот тут мне нужно пользователю Line
'разрешить доступ на запись/чтение к папке Line


Loop

Help! :help:

knight 01.02.2006 02:05

Посмотрите здесь насколько я помню там об этом шел разговор но не уверен:
http://rsdn.ru/article/com/wscript/WSH.xml?print

SabbaOff 01.02.2006 11:06

Хорошая статья, правильная...
Но в ней, как и в МСДН, как и в книжке Попова НЕТ ответа на мой вопрос:
КАК ДАТЬ ЮЗЕРУ "Х" ПРАВА НА ЧТЕНИЕ/ЗАПИСЬ ПАПКИ "У"
:confused:

LightImage 13.02.2006 11:25

В MSDN есть такой вот пример:
Код:

' Example Code
' The following VBScript example assumes that a folder named testfolder exists on C:\.
' The script obtains the security for this folder and changes the access permissions
' all the access control entries. For more information on security entities,
' see the Platform SDK section on Security. No error checking or handling is shown.


' The folder named "testfolder" must exist on the C:\ drive.
' Connect to WMI and get the file security object for the testfolder directory
Set wmiFileSecSetting = GetObject ("winmgmts:Win32_LogicalFileSecuritySetting.path='c:\\testfolder'")

' Use the Win32_LogicalFileSecuritySetting Caption property to create a simple header before
' dumping the discretionary access control list (DACL).
Wscript.Echo wmiFileSecSetting.Caption & ":" & vbCrLf

' Call the Win32_LogicalFileSecuritySetting GetSecurityDescriptor
' method to retrieve an instance of the Win32_SecurityDescriptor class
' for the target object, that is, C:\TestFolder. Note that this is achieved by
' passing an empty variable to GetSecurityDescriptor, which
' GetSecurityDescriptor in turn initializes with an instance of the
' Win32_SecurityDescriptor class that corresponds to the security
' descriptor for the target object.
RetVal = wmiFileSecSetting.GetSecurityDescriptor(wmiSecurityDescriptor)

' Retrieve the content of Win32_SecurityDescriptor DACL property.
' The DACL is an array of Win32_ACE objects.
DACL = wmiSecurityDescriptor.DACL

' Display the control flags in the descriptor.
Wscript.Echo "Control Flags:  " & wmiSecurityDescriptor.ControlFlags

' Obtain the trustee for each access control entry (ACE) and change the permissions
' in the AccessMask for each ACE to read, write, and delete.
For each wmiAce in DACL
' Get Win32_Trustee object from ACE
    Set Trustee = wmiAce.Trustee
    wscript.echo "Trustee Domain: "  & Trustee.Domain
    wscript.echo "Trustee Name: "    & Trustee.Name
    wscript.echo "Access Mask: "    & wmiAce.AccessMask
' Make access for every trustee read (1), write (2), and delete (65536) access
    wmiAce.AccessMask = 65539
    wscript.echo "Access Mask: "    & wmiAce.AccessMask           
Next

' Call the Win32_LogicalFileSecuritySetting.SetSecurityDescriptor method
' to write the new security descriptor.
RetVal = wmiFileSecSetting.SetSecurityDescriptor(wmiSecurityDescriptor)

Wscript.Echo "ReturnValue is:  " & RetVal


SabbaOff 13.02.2006 14:09

LightImage
Спасибо! Это именно то, что я искал!.. :yees:
Странно, что сам не смог найти.... :idontnow:


Часовой пояс GMT +4, время: 12:58.

Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.