powered by simpleCommunicator - 2.0.61     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / Visual Basic [игнор отключен] [закрыт для гостей] / Права пользователю на ветку реестра
14 сообщений из 14, страница 1 из 1
Права пользователю на ветку реестра
    #35624559
Romka_84
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Всем привет. У меня возникла огромная проблема. У меня есть ветка реестра, например, HKEY_LOCAL_MACHINE\SOFTWARE\Test . На нее даны права некоторым пользователям. Мне нужно сохраняя уже данные права дать полный доступ группе пользователей, например, FRIENDS . Не подскажите, как это можно сделать программно? Пробовал сделать на Delphi, но совсем запарился, решил попробовать на бейсике. Заранее благодарен.
...
Рейтинг: 0 / 0
Права пользователю на ветку реестра
    #35624890
Фотография Игорь Горбонос
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
> Автор: Romka_84
> Всем привет. У меня возникла огромная проблема. У меня есть ветка реестра, например,
> HKEY_LOCAL_MACHINE\SOFTWARE\Test. На нее даны права некоторым пользователям. Мне нужно сохраняя уже данные права дать
> полный доступ группе пользователей, например, FRIENDS. Не подскажите, как это можно сделать программно? Пробовал
> сделать на Delphi, но совсем запарился, решил попробовать на бейсике. Заранее благодарен.

Поищи в МСДН статью HOWTO: Set Security on a NTFS Folder Programmatically, и переделай её на реестр.

--
С уважением Горбонос Игорь Леонидович

Posted via ActualForum NNTP Server 1.4
...
Рейтинг: 0 / 0
Права пользователю на ветку реестра
    #35624902
Romka_84
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Игорь Горбонос,

У меня такая проблема что бейсик без хэлпа, не мог бы ты скинуть ссылку на эту статью
...
Рейтинг: 0 / 0
Права пользователю на ветку реестра
    #35625250
Фотография Игорь Горбонос
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
> Автор: Romka_84
> Игорь Горбонос,
>
> У меня такая проблема что бейсик без хэлпа, не мог бы ты скинуть ссылку на эту статью

Тынц

Вообще-то в гугле первая ссылка ;)
--
С уважением Горбонос Игорь Леонидович

Posted via ActualForum NNTP Server 1.4
...
Рейтинг: 0 / 0
Права пользователю на ветку реестра
    #35625585
Romka_84
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Нашел в инете код скрипта, он случаем не связам с правмами доступа

Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
Const KEY_QUERY_VALUE = &H0001
Const KEY_SET_VALUE = &H0002
Const KEY_CREATE_SUB_KEY = &H0004
Const DELETE = &H00010000
 
Const HKEY_LOCAL_MACHINE = &H80000002
 
strComputer = "."

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _ 
    strComputer & "\root\default:StdRegProv")
 
strKeyPath = "SYSTEM\CurrentControlSet"
 
oReg.CheckAccess HKEY_LOCAL_MACHINE, strKeyPath, KEY_QUERY_VALUE, _
    bHasAccessRight
If bHasAccessRight = True Then
    Wscript.Echo "Have Query Value Access Rights on Key"
Else
    Wscript.Echo "Do Not Have Query Value Access Rights on Key"
End If   
 
oReg.CheckAccess HKEY_LOCAL_MACHINE, strKeyPath, KEY_SET_VALUE, _
    bHasAccessRight
If bHasAccessRight = True Then
    Wscript.Echo "Have Set Value Access Rights on Key"
Else
    Wscript.Echo "Do Not Have Set Value Access Rights on Key"
End If   
 
oReg.CheckAccess HKEY_LOCAL_MACHINE, strKeyPath, KEY_CREATE_SUB_KEY, _
    bHasAccessRight
If bHasAccessRight = True Then
    Wscript.Echo "Have Create SubKey Access Rights on Key"
Else
    StdOut.WriteLine "Do Not Have Create SubKey Access Rights on Key"
End If
 
oReg.CheckAccess HKEY_LOCAL_MACHINE, strKeyPath, DELETE, bHasAccessRight
If bHasAccessRight = True Then
    StdOut.WriteLine "Have Delete Access Rights on Key"
Else
    StdOut.WriteLine "Do Not Have Delete Access Rights on Key"
End If
...
Рейтинг: 0 / 0
Права пользователю на ветку реестра
    #35625649
Фотография Игорь Горбонос
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
> Автор: Romka_84
> Нашел в инете код скрипта, он случаем не связам с правмами доступа

С правами, только в плане проверки прав на чтение/запись/создание/удаление.
Но их можно проверить и по другому, сделать попытку что-либо сделать и по успеху/неудаче(GetLastError) можно получить
ту-же информацию и она будет актуальна только для той учетной записи, под которой ты залогинился.

И ещё, для назначения прав на какие-то объекты другим пользователям, у тебя самого должны быть права на выдачу прав :)

--
С уважением Горбонос Игорь Леонидович

Posted via ActualForum NNTP Server 1.4
...
Рейтинг: 0 / 0
Права пользователю на ветку реестра
    #35625953
Romka_84
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Игорь Горбонос,

Права имеются, скачал пример, который ты посоветовал, там предыдущие права не сохраняются и сам файл он забирает в процесс.
...
Рейтинг: 0 / 0
Права пользователю на ветку реестра
    #35626053
Фотография Игорь Горбонос
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
> Автор: Romka_84
> Игорь Горбонос,
>
> Права имеются, скачал пример, который ты посоветовал, там предыдущие права не сохраняются

Когда-то(лет 5 назад), взяв его за основу, я доделал его для выставления прав на определенные ветки реестра и папки для
определенных пользователей
Естественно проекта найти сейчас не могу, но там нет ничего сложного, за день я сделал все что было нужно

> и сам файл он забирает в процесс.

Не понял

--
С уважением Горбонос Игорь Леонидович

Posted via ActualForum NNTP Server 1.4
...
Рейтинг: 0 / 0
Права пользователю на ветку реестра
    #35626353
Romka_84
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Игорь Горбонос,

Ты не мог бы еще скинуть мне ссылку на хэлп для бейсика
...
Рейтинг: 0 / 0
Права пользователю на ветку реестра
    #35626404
Фотография Игорь Горбонос
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
> Автор: Romka_84
> Игорь Горбонос,
>
> Ты не мог бы еще скинуть мне ссылку на хэлп для бейсика


К сожалению нет, т.к. сейчас msdn.microsoft.com перестроен и информация по старой студии находится с большим скрипом,
возможно у меня руки не достаточного радиуса закругления, но у меня есть локальный МСДН и я все( ну большую часть )
нахожу в нем, а в инет лезу когда нужна ссылка кому-то

--
С уважением Горбонос Игорь Леонидович

Posted via ActualForum NNTP Server 1.4
...
Рейтинг: 0 / 0
Права пользователю на ветку реестра
    #35626921
Romka_84
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Игорь Горбонос,

Начал писать под реестр и столкнулся с проблемой -

Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
    Dim strComputer As String
    Dim strKeyPath As String
    
    strComputer = "."

    Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
    strComputer & "\root\default:StdRegProv")
 
    strKeyPath = "SOFTWARE\BudgetBackUp"

Ругается что oReg не определена. Есть ли такая функция oReg.OpenKey чтобы открыть ключ или она не нужна?
...
Рейтинг: 0 / 0
Права пользователю на ветку реестра
    #35627104
Фотография Игорь Горбонос
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
> Автор: Romka_84
> Начал писать под реестр и столкнулся с проблемой -
>
>
> Dim strComputer As String
> Dim strKeyPath As String

> Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
> strComputer & "\root\default:StdRegProv")

> Ругается что oReg не определена. Есть ли такая функция oReg.OpenKey чтобы открыть ключ или она не нужна?

Естественно будет ругатся, объяви oReg:
Dim oReg As Object

--
С уважением Горбонос Игорь Леонидович

Posted via ActualForum NNTP Server 1.4
...
Рейтинг: 0 / 0
Права пользователю на ветку реестра
    #35627185
Romka_84
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Есть следующий код Какие маски надо задавать и как передавать в функцию считывающую права и Как добавить туда свою группу пользователей

Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
106.
107.
108.
109.
110.
111.
112.
113.
114.
115.
116.
117.
118.
119.
120.
121.
122.
123.
124.
125.
126.
127.
128.
129.
130.
131.
132.
133.
134.
135.
136.
137.
138.
139.
140.
141.
142.
143.
144.
145.
146.
147.
148.
149.
150.
151.
152.
153.
154.
155.
156.
157.
158.
159.
160.
161.
162.
163.
164.
165.
166.
167.
168.
169.
170.
171.
172.
173.
174.
175.
176.
177.
178.
179.
180.
181.
182.
183.
184.
185.
186.
187.
188.
189.
190.
191.
192.
193.
194.
195.
196.
197.
198.
199.
200.
201.
202.
203.
Private Sub Command1_Click()

    Dim rslt As Boolean
    Dim FirstAddReadMask As Long, SecondAddReadMask As Long
    
    Dim strComputer As String
    Dim strKeyPath As String
    Dim Oreg As Object
    
    strComputer = "."

    Set Oreg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
    strComputer & "\root\default:StdRegProv")
 
    strKeyPath = "SOFTWARE\BudgetBackUp"
    
    Oreg = Oreg + "\" + strKeyPath
    
    
    ' Add & Read
    'FirstAddReadMask = GENERIC_EXECUTE Or GENERIC_READ
    'SecondAddReadMask = READ_CONTROL Or SYNCHRONIZE Or &H1BF
                        ' (&h01bf standard rights for folder)
    'rslt = ChangePermission(Text1.Text, FirstAddReadMask, _
    '    SecondAddReadMask)
    'If Not rslt Then
    '    MsgBox "ChangePermission failed"
    'End If
    
End Sub

Private Function ChangePermission(sFName As String, FirstAceMask As Long, SecondAceMask As Long) As Boolean
   
   ' This function will set permissions for Folder specified in sFName
   ' FirstAceMask will set the mask for the files in the folder
   ' SecondAceMask will set the mask for the folder and subfolders.
   
   Dim udtSidIdentifierAuthority As SID_IDENTIFIER_AUTHORITY
   Dim udtAccessAllowedAce As ACCESS_ALLOWED_ACE
   Dim pSid As Long, ACLSize As Long
   Dim lAceSize As Long
   Dim x As Long
   Dim i As Integer
      
   ' To assign permissions you need to be a member of the
   ' Administrators group and the folder must be on an NTFS partition.
   For i =  0  To  4 
       udtSidIdentifierAuthority.Value(i) =  0 
   Next i
   udtSidIdentifierAuthority.Value( 5 ) =  5   ' SECURITY_NT_AUTHORITY
      
   Dim psdl As Long ' used to get security descriptor pointer
   
   ' Initialize Security Descriptor - the first paramter is address of the
   ' security descriptor.
   x = InitializeSecurityDescriptor(VarPtr(psdl), _
       SECURITY_DESCRIPTOR_REVISION)
   If x =  0  Then
       MsgBox "InitializeSecurityDescriptor failed"
       Exit Function
   End If
   
   ' Allocate and initialize a Sid; Administrative group
   ' The first parameter is the Sid Authority Identifier which identifies
   '    the top level authority which is the administrators group.
   ' The second parameter indicates that there are 2 subauthorities to
   '    be placed in the SID.
   ' The two subauthorities SECURITY_BUILTIN_DOMAIN_RID and
   '    DOMAIN_ALIAS_RID_ADMINS are RID identifiers for the
   '    Administrators group.
   ' The RID is the Relative Identifier found in the SID that identifies
   '    the user or group.  In this case it identifies the Administrators
   '    group.
   ' The combinded SID and RIDs identify the Administrators group.
   ' The last paramter, pSid is a pointer to a pointer to the sid.
   '    It is passed byref here and later dereferenced passing byval.
   '    It is passed byval in GetLengthSid, CopySid and FreeSid.
   x = AllocateAndInitializeSid(udtSidIdentifierAuthority,  2 , _
            SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, _
             0 ,  0 ,  0 ,  0 ,  0 ,  0 , pSid)
   If x =  0  Then
       MsgBox "AllocateAndInitializeSid failed"
       Exit Function
   End If
   
   ' Calculate length of ACL
   Dim AnAcl As ACL, AnAAA As ACCESS_ALLOWED_ACE
   
   ACLSize = Len(AnAcl) + Len(AnAAA) - Len(x) + GetLengthSid(pSid) + _
           Len(AnAAA) - Len(x) + GetLengthSid(pSid)
    
   ' Allocate memory for ACL
   ReDim bufACL(ACLSize -  1 ) As Byte
   
   ' Init the ACL
   ' Creates a new ACL structure.  This is a variable length structure.
   ' A byte array is created to hold the contiguous bytes.  The size of
   ' this buffer was calculated above in ACLSize.  In this call the pointer
   ' to the first element of the array is passed.
   ' The third parameter must be ACL_REVISION.
   x = InitializeAcl(bufACL( 0 ), ACLSize, ACL_REVISION)
   If x =  0  Then
       MsgBox "InitializeAcl failure"
       Exit Function
   End If
     
   ' Set values in AllowedAccessAce structure:
   ' It is easier to assign values using UDT notation.
   ' There are 2 types of ACEs.  Access allowed and Access denied.
   ' This field indicates that we are using an Access allowed ACE.
   udtAccessAllowedAce.Header.AceType = ACCESS_ALLOWED_ACE_TYPE
   ' AceFlags field specifies control flags.
   ' INHERIT_ONLY_ACE does not apply to containers (folder) but to objects
   ' in the container (files).
   ' OBJECT_INHERIT_ACE indicates that the ACE is inherited by
   ' non container objects such as files within the container object
   ' to which the ACE is assigned.
   udtAccessAllowedAce.Header.AceFlags = _
       INHERIT_ONLY_ACE Or OBJECT_INHERIT_ACE
   ' Size of the ACE
   lAceSize = Len(AnAAA) - Len(x) + GetLengthSid(pSid)
   udtAccessAllowedAce.Header.AceSize = lAceSize
   ' The Mask specifies access rights granted to the ACE.
   ' See SDK documentation under ACCESS_MASK for the break down by bits.
   udtAccessAllowedAce.Mask = FirstAceMask
   ReDim bufAce(lAceSize -  1 ) As Byte
   ' Copy the AccessAllowedAce structure(UDT) to buffer.
   CopyMemory bufAce( 0 ), udtAccessAllowedAce, lAceSize
   ' Copy sid to buffer where bufAce is the destination buffer -
   ' pSid is ptr to source SID.
   ' y(8) corresponds to SidStart field in AccessAllowedAce struct.
   x = CopySid(GetLengthSid(pSid), bufAce( 8 ), pSid)
    If x =  0  Then
       MsgBox "CopySid fail " & Err.LastDllError
       Exit Function
    End If
       
    ' Add an ACE to ACL.  This is done twice.
    ' This first AddAce call applies to files in the folder.
    ' The first parameter is a pointer to the variable length ACL which is
    '     passed using a pointer to the first element in a byte array.
    ' The second parameter needs to be ACL_REVISION.
    ' The third paramter specifies the position of the ACE in the
    '    ACL which in this case is at the end.
    ' The fourth parameter is a pointer to one or more ACEs.
    '    These ACEs would be placed in contiguous memory and are
    '    placed in a byte array the size
    ' which is placed in the last parameter.
    x = AddAce(bufACL( 0 ), ACL_REVISION, MAXDWORD, bufAce( 0 ), _
        udtAccessAllowedAce.Header.AceSize)
    If x =  0  Then
        MsgBox "First AddAce failed " & Err.LastDllError
    End If
    
    CopyMemory udtAccessAllowedAce, bufAce( 0 ), _
        udtAccessAllowedAce.Header.AceSize
        
    udtAccessAllowedAce.Mask = SecondAceMask
    udtAccessAllowedAce.Header.AceFlags = CONTAINER_INHERIT_ACE

    CopyMemory bufAce( 0 ), udtAccessAllowedAce, _
        udtAccessAllowedAce.Header.AceSize
   
    
    ' bufACL(0) - ptr to first element in byte array that
    ' contains contents of the acl structure - ACE gets added to this ACL
    ' which contains ACEs stored contiguously.
    ' This ACE applies to directories and subdirectories.
        
    x = AddAce(bufACL( 0 ), ACL_REVISION, MAXDWORD, bufAce( 0 ), _
        udtAccessAllowedAce.Header.AceSize)
    If x =  0  Then
        MsgBox "Second AddAce failed " & Err.LastDllError
    End If
        
    ' Set the DACL in the security descriptor
    ' The first paramter is the pointer to the security descriptor.
    ' The second paramter is boolean indicating the presence of a DACL
    ' in the Security Descriptor.
    ' The third parameter is the address of the DACL which is variable
    ' length and passed in a byte array.
    ' The fourth paramter indicates that DACL is created by user.
    x = SetSecurityDescriptorDacl(VarPtr(psdl),  1 , bufACL( 0 ),  0 )
    If x =  0  Then
       MsgBox "SetSecurityDescriptorDacl failure " & Err.LastDllError
       Exit Function
    End If
    
    Dim si As Long
    si = DACL_SECURITY_INFORMATION
   
    ' Set security on Folder object
    x = SetFileSecurity(sFName, si, VarPtr(psdl))
    If x =  0  Then
        MsgBox "SetFileSecurity failure " & Err.LastDllError
        Exit Function
    End If
    
    ' Free Sid
    FreeSid pSid
    
    ChangePermission = True
    
End Function 
...
Рейтинг: 0 / 0
Права пользователю на ветку реестра
    #35635508
Romka_84
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Че-то ничего не получается, всякая хрень лезет а нужного результата нет.
...
Рейтинг: 0 / 0
14 сообщений из 14, страница 1 из 1
Форумы / Visual Basic [игнор отключен] [закрыт для гостей] / Права пользователю на ветку реестра
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]