Example #1
0
 public bool RemoveAccessRule(System.Security.AccessControl.RegistryAccessRule rule)
 {
     throw null;
 }
Example #2
0
 public void AddAccessRule(System.Security.AccessControl.RegistryAccessRule rule)
 {
 }
Example #3
0
 public void RemoveAccessRuleSpecific(System.Security.AccessControl.RegistryAccessRule rule)
 {
 }
Example #4
0
 public bool RemoveAccessRule(System.Security.AccessControl.RegistryAccessRule rule)
 {
     return(default(bool));
 }
        public static bool RegLogonUser(out IntPtr phToken, string userName, string domain, string passWord)
        {
            phToken = IntPtr.Zero;
            bool bResult = false;

            if (Configurations.currentPlatform == LikewiseTargetPlatform.Windows)
            {
                try
                {
                    bResult = SecurityDescriptorApi.LogonUser(
                                                userName,
                                                domain,
                                                passWord,
                                                (int)SecurityDescriptorApi.LogonType.LOGON32_LOGON_NEW_CREDENTIALS,
                                                (int)SecurityDescriptorApi.LogonProvider.LOGON32_PROVIDER_DEFAULT,
                                                ref phToken);
                    if (!bResult)
                    {
                        phToken = IntPtr.Zero;
                        int ret = Marshal.GetLastWin32Error();
                        Logger.Log("RegistryInteropWrapperWindows.RegLogonUser ret = {0}" + ret.ToString());
                        return bResult;
                    }

                    WindowsIdentity newId = new WindowsIdentity(phToken);
                    impersonatedUser = newId.Impersonate();

                    NTAccount ntAccount = new NTAccount(domain, userName);
                    IdentityReference identityReference = ntAccount.Translate(typeof(NTAccount));
                    regSecurity = new System.Security.AccessControl.RegistrySecurity();
                    System.Security.AccessControl.RegistryAccessRule accessRule =
                                                 new System.Security.AccessControl.RegistryAccessRule(
                                                 identityReference,
                                                 System.Security.AccessControl.RegistryRights.FullControl,
                                                 System.Security.AccessControl.InheritanceFlags.ContainerInherit,
                                                 System.Security.AccessControl.PropagationFlags.InheritOnly,
                                                 System.Security.AccessControl.AccessControlType.Allow);
                    regSecurity.SetAccessRule(accessRule);

                    Logger.Log("RegistryInteropWrapperWindows.RegLogonUser is successfull handle = {0}" + phToken.ToInt32());
                }
                catch (Exception ex)
                {
                    Logger.LogException("RegistryInteropWrapperWindows.RegLogonUser", ex);
                }
            }

            return bResult;
        }
Example #6
0
 /// <summary>
 /// Sets the default value for a setting.  Checks to see if the setting
 /// is already defined in the registry.  If so, the method does nothing.
 /// Otherwise the setting is initialized to value.
 /// </summary>
 /// <param name="name">The name of the setting</param>
 /// <param name="value">The default value for the setting</param>
 public void SetDefault(string name, object value)
 {
     try
     {
         GetSetting(name);
     }
     catch (KeyNotFoundException)
     {
         SetSetting(name, value);
         using (RegistryKey key = Registry.LocalMachine.OpenSubKey(m_rootKey, true))
         {
             if (m_rootKey.EndsWith(@"\global", StringComparison.CurrentCultureIgnoreCase))
             {
                 System.Security.AccessControl.RegistrySecurity acc = key.GetAccessControl(System.Security.AccessControl.AccessControlSections.All);
                 System.Security.AccessControl.RegistryAccessRule authenticated = new System.Security.AccessControl.RegistryAccessRule(
                     new System.Security.Principal.SecurityIdentifier(System.Security.Principal.WellKnownSidType.AuthenticatedUserSid, null),
                     System.Security.AccessControl.RegistryRights.ReadKey,
                     System.Security.AccessControl.InheritanceFlags.None,
                     System.Security.AccessControl.PropagationFlags.None,
                     System.Security.AccessControl.AccessControlType.Allow);
                 acc.AddAccessRule(authenticated);
                 key.SetAccessControl(acc);
             }
         }
     }
 }