internal static unsafe void CreateCimCredential(string authenticationMechanism, string certificateThumbprint, out NativeCimCredentialHandle credentialHandle) { IntPtr hGlobalUni = Marshal.StringToHGlobalUni(authenticationMechanism); IntPtr intPtr = Marshal.StringToHGlobalUni(certificateThumbprint); credentialHandle = new NativeCimCredentialHandle(intPtr, true, null); }
internal static unsafe void CreateCimCredential(string authenticationMechanism, string domain, string userName, SecureString password, out NativeCimCredentialHandle credentialHandle) { IntPtr hGlobalUni = Marshal.StringToHGlobalUni(authenticationMechanism); IntPtr intPtr = Marshal.StringToHGlobalUni(domain); IntPtr hGlobalUni1 = Marshal.StringToHGlobalUni(userName); credentialHandle = new NativeCimCredentialHandle(hGlobalUni1, false, password); }
internal static unsafe void CreateCimCredential(string authenticationMechanism, out NativeCimCredentialHandle credentialHandle) { IntPtr hGlobalUni = Marshal.StringToHGlobalUni(authenticationMechanism); credentialHandle = new NativeCimCredentialHandle(hGlobalUni, false, null); }
internal static unsafe MiResult AddDestinationCredentials(DestinationOptionsHandle destinationOptionsHandle, NativeCimCredentialHandle credentials) { NativeDestinationOptions options = CimNativeApi.MarshalledObject.FromPointer<NativeDestinationOptions>(destinationOptionsHandle.DangerousGetHandle ()); string userName = Marshal.PtrToStringUni(credentials.DangerousGetHandle ()); SecureString pwd = credentials.GetSecureString (); options.UserName = userName; options.Password = CimNativeApi.GetPassword(pwd); IntPtr ptr = (IntPtr)CimNativeApi.MarshalledObject.Create<NativeDestinationOptions>(options); destinationOptionsHandle.DangerousSetHandle (ptr); /* DangerousHandleAccessor dangerousHandleAccessor = null; DangerousHandleAccessor dangerousHandleAccessor1 = null; _MI_Result _MIResult = 0; DangerousHandleAccessor dangerousHandleAccessor modopt(System.Runtime.CompilerServices.IsConst) = new DangerousHandleAccessor(destinationOptionsHandle); try { _MI_DestinationOptions* _MIDestinationOptionsPointer = (_MI_DestinationOptions*)((void*)dangerousHandleAccessor.DangerousGetHandle()); if (_MIDestinationOptionsPointer != null) { if ((long)(*(_MIDestinationOptionsPointer + (long)16)) != 0) { DangerousHandleAccessor modopt(System.Runtime.CompilerServices.IsConst) dangerousHandleAccessor modopt(System.Runtime.CompilerServices.IsConst)1 = new DangerousHandleAccessor(credentials); try { dangerousHandleAccessor1 = dangerousHandleAccessor modopt(System.Runtime.CompilerServices.IsConst)1; _MI_UserCredentials* _MIUserCredentialsPointer = (_MI_UserCredentials*)((void*)dangerousHandleAccessor1.DangerousGetHandle()); SecureString secureString = credentials.GetSecureString(); IntPtr zero = IntPtr.Zero; if (secureString == null || secureString.Length <= 0) { *(_MIUserCredentialsPointer + (long)24) = (long)0; } else { IntPtr globalAllocUnicode = Marshal.SecureStringToGlobalAllocUnicode(secureString); zero = globalAllocUnicode; *(_MIUserCredentialsPointer + (long)24) = (void*)globalAllocUnicode; } try { _MIResult = (_MI_Result)<Module>.?A0x5fa54d02.MI_DestinationOptions_AddDestinationCredentials(_MIDestinationOptionsPointer, _MIUserCredentialsPointer); } finally { if (zero != IntPtr.Zero) { Marshal.ZeroFreeGlobalAllocUnicode(zero); } } } dangerousHandleAccessor1.Dispose(); dangerousHandleAccessor.Dispose(); return (MiResult)_MIResult; } } } dangerousHandleAccessor.Dispose(); */ return MiResult.OK; }