/// <summary> /// マネージドの値を元にアンマネージドにコピーする /// </summary> /// <param name="Credential"></param> /// <returns>解放用のオブジェクト</returns> public IDisposable Copy(WinCred.Credential Credential) { var Disposables = new List <IDisposable>(); var ResultDisposable = Disposable.Create(() => { foreach (var d in Enumerable.Reverse(Disposables)) { d?.Dispose(); } }); try { Flags = Credential.Flags; Type = Credential.Type; TargetName = Credential.TargetName; Comment = Credential.Comment; LastWritten = Credential.LastWritten.ToFILETIMEStructure(); CredentialBlobSize = 0; CredentialBlobPtr = IntPtr.Zero; Persist = Credential.Persist; TargetAlias = Credential.TargetAlias; UserName = Credential.UserName; AttributeCount = 0; AttributesPtr = IntPtr.Zero; Disposables.Add(CopyAttributes(Credential.Attributes)); Disposables.Add(CopyCredentialBlob(Credential.CredentialBlob)); return(ResultDisposable); } catch { ResultDisposable?.Dispose(); throw; } }
/// <summary> /// マネージドな Credential からの生成 /// </summary> /// <param name="Credential"></param> public Credential(WinCred.Credential Credential) { Flags = Credential.Flags; Type = Credential.Type; TargetName = Credential.TargetName; Comment = Credential.Comment; LastWritten = Credential.LastWritten.ToFILETIMEStructure(); CredentialBlobSize = 0; CredentialBlobPtr = IntPtr.Zero; Persist = Credential.Persist; TargetAlias = Credential.TargetAlias; UserName = Credential.UserName; AttributeCount = 0; AttributesPtr = IntPtr.Zero; }