On 2004-04-17, James <Lo**@postforemail.com> wrote:
I would like to get a user's first name and last name instead of just their
username. According to this link,
http://msdn.microsoft.com/library/de...l=/library/en-
us/sysinfo/base/translatename.asp
there is a function that will do that if I use the NameDisplay member of
the Extended_Name_Format enumeration in the function call, but I can't
figure out how to implement it in VB. It seems to be an API call, but I
can't find an acceptable Declare for it. I've googled the web and Usenet
and can't find much documentation.
Any help would be appreciated.
Thanks,
James
AirCode!
<Flags()> _
Public Enum EXTENDED_NAME_FORMAT
NameUnknown = 0
NameFullyQualifiedDN = 1
NameSamCompatible = 2
NameDisplay = 3
NameUniqueId = 6
NameCanonical = 7
NameUserPrincipal = 8
NameCanonicalEx = 9
NameServicePrincipal = 10
NameDnsDomain = 12
End Enum
Public Declare Auto Function TranslateName Lib "secur32" _
(ByVal lpAccountName As String, _
ByVal AccountNameFormat As EXTENDED_NAME_FORMAT, _
ByVal DesiredNameFormat As EXTENDED_NAME_FORMAT, _
ByVal lpTranslatedName As System.Text.StringBuilder, _
ByRef nSize As Integer) As Boolean
Dim translatedName As New StringBuilder(256)
Dim nSize As Integer = translatedName.Capacity
If Not TranslateName( _
"TheAccountName",
EXTENDED_NAME_FORMAT.NameSamCopatible, _
EXTENDED_NAME_FORMAT.NameDisplay, _
translatedName, _
nSize) Then
Dim ex As New _
System.ComponentModel.Win32Exception( _
Marshal.GetLastWin32Error())
MessageBox.Show(ex.Message)
Else
MessageBox.Show(translatedName.ToString())
End If
HTH
--
Tom Shelton [MVP]
Powered By Gentoo Linux 1.4
God made everything out of nothing, but the nothingness shows through.
-- Paul Valery