Added support for querying a credential's name.

This commit is contained in:
antiduh
2014-06-19 03:07:34 +00:00
parent f96ef74e9b
commit f0f057d3bb
5 changed files with 116 additions and 4 deletions

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.DirectoryServices.AccountManagement;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
@@ -101,9 +102,33 @@ namespace NSspi
}
}
public string GetName()
public string Name
{
return null;
get
{
NativeMethods.QueryNameAttribCarrier carrier = new NativeMethods.QueryNameAttribCarrier();
SecurityStatus status;
string name = null;
status = NativeMethods.QueryCredentialsAttribute_Name(
ref this.credHandle,
CredentialQueryAttrib.Names,
ref carrier
);
if ( status == SecurityStatus.Success )
{
name = Marshal.PtrToStringUni( carrier.Name );
NativeMethods.FreeContextBuffer( carrier.Name );
}
else
{
throw new SSPIException( "Failed to query credential name", status );
}
return name;
}
}
public long CredentialHandle