473,491 Members | 2,524 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

TranslateName Function/API Call?

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
Nov 20 '05 #1
1 1794
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
Nov 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
2672
by: JKop | last post by:
Take the following simple function: unsigned long Plus5Percent(unsigned long input) { return ( input + input / 20 ); } Do yous ever consider the possibly more efficent:
2
7658
by: laredotornado | last post by:
Hello, I am looking for a cross-browser way (Firefox 1+, IE 5.5+) to have my Javascript function execute from the BODY's "onload" method, but if there is already an onload method defined, I would...
13
4096
by: Bern McCarty | last post by:
I have run an experiment to try to learn some things about floating point performance in managed C++. I am using Visual Studio 2003. I was hoping to get a feel for whether or not it would make...
9
3259
by: CryptiqueGuy | last post by:
Consider the variadic function with the following prototype: int foo(int num,...); Here 'num' specifies the number of arguments, and assume that all the arguments that should be passed to this...
0
6978
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7154
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7190
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6858
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
4881
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3086
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3076
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1392
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
280
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.