P
Parv
I am working in a domain environment. I am on a client machine and
wants to edit registery of domain server. I am currently in a Domain
user account and member of Domain administrators on the domain
controller. I am able to open registry manully by connecting the remote
registry. While doing the same programatically i am getting the
following exception :
CODE :
RegistryKey baseKey =
RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, "server");
RegistryKey sk1 =
baseKey.OpenSubKey(@"SYSTEM\CurrentControlSet\Services\EXIFS\Parameters");
string key = "incoming";
sk1.CreateSubKey(key);
sk1.SetValue(key, 1, RegistryValueKind.DWord);
EXCEPTION:
System.UnauthorizedAccessException was unhandled
Message="Cannot write to the registry key."
Source="mscorlib"
StackTrace:
at
System.ThrowHelper.ThrowUnauthorizedAccessException(ExceptionResource
resource)
at Microsoft.Win32.RegistryKey.CreateSubKey(String subkey,
RegistryKeyPermissionCheck permissionCheck, RegistrySecurity
registrySecurity)
at Microsoft.Win32.RegistryKey.CreateSubKey(String subkey)
at MyEventSink.ExchangeConnect.SendMessage.Main(String[] srgs)
in D:\Parv\Data\Visual
Basic\MyEventSink\ExchangeConnect\SendMessage.cs:line 53
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[]
args)
at System.Runtime.Hosting.ManifestRunner.Run(Boolean
checkAptModel)
at System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()
at
System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext
activationContext, String[] activationCustomData)
at
System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext
activationContext)
at
Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
at System.Threading.ThreadHelper.ThreadStart_Context(Object
state)
at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
What i am doing wrong ?
Thanx in advance.
With Best Regards
Parveen Beniwal
wants to edit registery of domain server. I am currently in a Domain
user account and member of Domain administrators on the domain
controller. I am able to open registry manully by connecting the remote
registry. While doing the same programatically i am getting the
following exception :
CODE :
RegistryKey baseKey =
RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, "server");
RegistryKey sk1 =
baseKey.OpenSubKey(@"SYSTEM\CurrentControlSet\Services\EXIFS\Parameters");
string key = "incoming";
sk1.CreateSubKey(key);
sk1.SetValue(key, 1, RegistryValueKind.DWord);
EXCEPTION:
System.UnauthorizedAccessException was unhandled
Message="Cannot write to the registry key."
Source="mscorlib"
StackTrace:
at
System.ThrowHelper.ThrowUnauthorizedAccessException(ExceptionResource
resource)
at Microsoft.Win32.RegistryKey.CreateSubKey(String subkey,
RegistryKeyPermissionCheck permissionCheck, RegistrySecurity
registrySecurity)
at Microsoft.Win32.RegistryKey.CreateSubKey(String subkey)
at MyEventSink.ExchangeConnect.SendMessage.Main(String[] srgs)
in D:\Parv\Data\Visual
Basic\MyEventSink\ExchangeConnect\SendMessage.cs:line 53
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[]
args)
at System.Runtime.Hosting.ManifestRunner.Run(Boolean
checkAptModel)
at System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()
at
System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext
activationContext, String[] activationCustomData)
at
System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext
activationContext)
at
Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
at System.Threading.ThreadHelper.ThreadStart_Context(Object
state)
at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
What i am doing wrong ?
Thanx in advance.
With Best Regards
Parveen Beniwal