Exemple #1
0
        public void SetIpsecSecurityLocal(IpsecFlags securityFlags, SecureString ipsecKey)
        {
            if (ipsecKey == null)
            {
                throw new ArgumentNullException("ipsecKey", "ipsecKey cannot be set to null");
            }
            this.InitializeComInterfaces();
            if (this.portalLocal == null)
            {
                throw new NotSupportedException("The portal is not a local portal");
            }
            SecureStringAnsiHandle handle = new SecureStringAnsiHandle(ipsecKey);

            try
            {
                IpsecKey key = new IpsecKey(handle);
                this.portalLocal.SetIpsecSecurityLocal(securityFlags, ref key);
            }
            catch (COMException exception)
            {
                throw new VdsException("The call to IVdsIscsiPortalLocal::SetIpsecSecurityLocal failed.", exception);
            }
            finally
            {
                if (handle != null)
                {
                    handle.Dispose();
                }
            }
        }
Exemple #2
0
        public void SetSharedSecret(SecureString targetSharedSecret, string initiatorName)
        {
            if (targetSharedSecret == null)
            {
                throw new ArgumentNullException("targetSharedSecret", "Cannot pass in null for shared secret");
            }
            this.InitializeComInterfaces();
            SecureStringAnsiHandle sharedSecret = new SecureStringAnsiHandle(targetSharedSecret);

            try
            {
                SharedSecret secret = new SharedSecret(sharedSecret);
                this.target.SetSharedSecret(ref secret, initiatorName);
            }
            catch (COMException exception)
            {
                throw new VdsException("The call to IVdsIscsiTarget::SetSharedSecret failed.", exception);
            }
            finally
            {
                if (sharedSecret != null)
                {
                    sharedSecret.Dispose();
                }
            }
        }