public static uint ApiBuildTrusteeWithSid(IntPtr pSid, out SecurityDescriptorApi.TRUSTEE Trustee) { uint errorReturn = 0; IntPtr pTrustee = IntPtr.Zero; Trustee = new SecurityDescriptorApi.TRUSTEE(); try { Logger.Log("SecurityDescriptorWrapper.ApiBuildTrusteeWithSid() called", Logger.SecurityDescriptorLogLevel); pTrustee = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(SecurityDescriptorApi.TRUSTEE))); bool bRet = SecurityDescriptorApi.BuildTrusteeWithSid(ref pTrustee, pSid); errorReturn = (uint)Marshal.GetLastWin32Error(); Logger.Log("Build trustee returns" + errorReturn); if (pTrustee != IntPtr.Zero) { Trustee = new SecurityDescriptorApi.TRUSTEE(); Trustee = (SecurityDescriptorApi.TRUSTEE)Marshal.PtrToStructure(pTrustee, typeof(SecurityDescriptorApi.TRUSTEE)); } } catch (Exception ex) { errorReturn = (uint)Marshal.GetLastWin32Error(); Logger.LogException("SecurityDescriptorWrapper.ApiBuildTrusteeWithSid()", ex); Logger.Log("Build trustee " + Marshal.GetLastWin32Error()); } return(errorReturn); }
public static uint ApiBuildTrusteeWithSid(IntPtr pSid, out SecurityDescriptorApi.TRUSTEE Trustee) { uint errorReturn = 0; IntPtr pTrustee = IntPtr.Zero; Trustee = new SecurityDescriptorApi.TRUSTEE(); try { Logger.Log("SecurityDescriptorWrapper.ApiBuildTrusteeWithSid() called", Logger.SecurityDescriptorLogLevel); pTrustee = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(SecurityDescriptorApi.TRUSTEE))); bool bRet = SecurityDescriptorApi.BuildTrusteeWithSid(ref pTrustee, pSid); errorReturn = (uint)Marshal.GetLastWin32Error(); Logger.Log("Build trustee returns" + errorReturn); if (pTrustee != IntPtr.Zero) { Trustee = new SecurityDescriptorApi.TRUSTEE(); Trustee = (SecurityDescriptorApi.TRUSTEE)Marshal.PtrToStructure(pTrustee, typeof(SecurityDescriptorApi.TRUSTEE)); } } catch (Exception ex) { errorReturn = (uint)Marshal.GetLastWin32Error(); Logger.LogException("SecurityDescriptorWrapper.ApiBuildTrusteeWithSid()", ex); Logger.Log("Build trustee " + Marshal.GetLastWin32Error()); } return errorReturn; }