Opc.Ua.Configuration.LocalSecurityPolicy.GetSIDInformation C# (CSharp) Method

GetSIDInformation() private method

private GetSIDInformation ( string account ) : IntPtr
account string
return System.IntPtr
        IntPtr GetSIDInformation(string account)
        {
            //pointer an size for the SID
			IntPtr sid = IntPtr.Zero;
			int sidSize = 0;
            //StringBuilder and size for the domain name
			StringBuilder domainName = new StringBuilder();
			int nameSize = 0;
			//account-type variable for lookup
			int accountType = 0;

			//get required buffer size
            LookupAccountName(String.Empty, account, sid, ref sidSize, domainName, ref nameSize, ref accountType);
			
			//allocate buffers
			domainName = new StringBuilder(nameSize);
			sid = Marshal.AllocHGlobal(sidSize);

			//lookup the SID for the account
            bool result = LookupAccountName(String.Empty, account, sid, ref sidSize, domainName, ref nameSize, ref accountType);			
            if(!result)
            {
                Marshal.ThrowExceptionForHR(GetLastError());
            }    
            return sid;
        }