|
-
Mar 29th, 2001, 01:11 PM
#1
Thread Starter
Black Cat
I'm trying to use the following Windows 2000 API call. It returns an error (retval = 0) when I pass it any EXTENDED_NAME_FORMAT besides NameSamCompatible. Why is that? Is there some security API call I'd have to call first? The MSDN documentation looks like they all should work.
Thanks,
Josh
Code:
Private Enum EXTENDED_NAME_FORMAT
NameUnknown = 0 '???
NameFullyQualifiedDN = 1 'Full Active Directory style name?
NameSamCompatible = 2 'NT 4 style DOMAIN\user
NameDisplay = 3 'Friendly Name?
NameUniqueId = 6
NameCanonical = 7
NameUserPrincipal = 8
NameCanonicalEx = 9
NameServicePrincipal = 10
End Enum
Private Declare Function GetUserNameEx Lib "secur32.dll" Alias "GetUserNameExA" _
(ByVal NameFormat As EXTENDED_NAME_FORMAT, ByVal lpbuffer As String, nsize As Long) _
As Long
Private Sub Command2_Click()
Dim username As String 'string buffer that gets User's Name
Dim slength As Long 'length of the string buffer
Dim retval As Long 'return value, 0 if error
username = Space(255)
slength = 255
retval = GetUserNameEx(NameSamCompatible, username, slength)
username = Left(username, slength - 1)
Text2.Text = username
End Sub
Josh
Get these: Mozilla Opera OpenBSD
I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.
-
Mar 30th, 2001, 07:22 AM
#2
Thread Starter
Black Cat
Anyone at least try this on Windows 2000 and see if they get the same results I did? I'm suspecting something to do with Active Directory...
Josh
Get these: Mozilla Opera OpenBSD
I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.
-
Mar 31st, 2001, 08:42 PM
#3
Lively Member
It worked fine for me
retval = 1
text2.text= what it should be
I'm using windows 2k with service pack 1
Krushstone
-
Apr 2nd, 2001, 06:09 AM
#4
Thread Starter
Black Cat
Did you try anything besides NameSamCompatible here?
Code:
retval = GetUserNameEx(NameSamCompatible, username, slength)
Nothing else seems to work.
Josh
Get these: Mozilla Opera OpenBSD
I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|