Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,24 @@ internal static class UnsafeNativeMethods
{
public static int ADsOpenObject(string path, string userName, string password, int flags, [In, Out] ref Guid iid, [Out, MarshalAs(UnmanagedType.Interface)] out object ppObject)
{
IntPtr ppObjPtr = IntPtr.Zero;
try
{
int hr = Interop.Activeds.ADsOpenObject(path, userName, password, flags, ref iid, out IntPtr ppObjPtr);
int hr = Interop.Activeds.ADsOpenObject(path, userName, password, flags, ref iid, out ppObjPtr);
ppObject = Marshal.GetObjectForIUnknown(ppObjPtr);
return hr;
}
catch (EntryPointNotFoundException)
{
throw new InvalidOperationException(SR.AdsiNotInstalled);
}
finally
{
if (ppObjPtr != IntPtr.Zero)
{
Marshal.Release(ppObjPtr);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to add a unit test for this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know enough about this space to add a unit test and testing specifically if we leak a COM object here is difficult.

}
}
}

//
Expand Down