Re: getting info from active directory

From: Randy Birch (rgb_removethis_at_mvps.org)
Date: 04/23/04


Date: Fri, 23 Apr 2004 09:07:21 -0400

Actually, to be accurate GetUserName returns the user name of the current
thread. This is the normally the name of the user currently logged onto the
system, but if the thread is impersonating another client it returns the
user name of the client that the thread is impersonating. I suspect
<educated guess-mode on> this is only of concern if the app is run as a
service, or possibly if an impersonation call is used (ie to perform a task
as the administrator).

-- 
Randy Birch
MVP Visual Basic
http://vbnet.mvps.org/
Please respond only to the newsgroups so all can benefit.
"Paras Wadehra" <paraswadehra@Please_Remove_This_Hotmail.com> wrote in 
message news:#Hxev7KKEHA.3924@tk2msftngp13.phx.gbl...
: The following function will work if you want to fetch the username of the
: person logged into Windows (Just call the UserName function):
:
:
: Public Function UserName() As String
:
:   Dim cn As String
:   Dim ls As Long
:   Dim res As Long
:
:   cn = String(1024, 0)
:   ls = 1024
:   res = GetUserName(cn, ls)
:   If res <> 0 Then
:       UserName = Mid(cn, 1, InStr(cn, Chr(0)) - 1)
:   Else
:       UserName = ""
:   End If
:
: End Function
:
: -- 
: Paras Wadehra
:
: You One Stop Entertainment Guide - http://www.paras.2ya.com/
:
: "Andre" <agibson_@hotmail.com> wrote in message
: news:675F9D96-C04E-46AC-BC0F-D27D7EA77CC2@microsoft.com...
: > hi all
: >
: > Does anyone know where I can find a snippet of code the explains how I 
can
: pull info from active directory?
: >
: > Thanks
: >
: >
:
: 


Relevant Pages

  • Re: Macro to send email to person in workbook list of users
    ... I'm not sure where you get the username or where that table is, ... dim res as variant ... dim myTable as range ... Set OutApp = CreateObject ...
    (microsoft.public.excel.programming)
  • Re: getting info from active directory
    ... The following function will work if you want to fetch the username of the ... Public Function UserNameAs String ... Dim cn As String ... Dim res As Long ...
    (microsoft.public.vb.general.discussion)
  • Re: Usernametoken cant beused inweb services that are invoked bywebcl
    ... you still use the built-in username token manager which can only handle windows accounts - you have to register your own in web.config ... Dim aa As String Dim bb As String ... SoapException("Missing security token", SoapException.ClientFaultCode) ... apEnvelope envelope) at ...
    (microsoft.public.dotnet.security)
  • Re: WSE 3.O Web Service with ASP.Net Client using VB.Net
    ... <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"</a>;> ... ''' Constructs an instance of this security token manager. ... Dim principal As GenericPrincipal = New ... There is a logon page which takes a Username and Password, ...
    (microsoft.public.dotnet.framework.webservices.enhancements)
  • Return Value?
    ... Public Class UserDetails ... Public FirstName As String ... Public Function Login(ByVal UserName As String, ... Dim sqlCmd As SqlCommand ...
    (microsoft.public.dotnet.framework.aspnet)

Quantcast