Find which server user is logged onto 
Author Message
 Find which server user is logged onto

Hello

Using Office 97, SR-2 on Windows 2000 V5.0, SP-3.

As part of an Excel template I've been working on, one of the pieces of
information I need is the full path to the server that the user is currently
connected to.  I tried using the ActiveWorkbook.Path property, but this gave
me the drive mapping rather than the full path including server name.

Is there a relatively easy way to get this information?  It would really be
most useful to my application.

Many thanks in advance

Denise Crawley



Mon, 04 Jul 2005 18:28:03 GMT  
 Find which server user is logged onto
Once you know the drive letter you can get the mapping like this:

Declare Function WNetGetConnection Lib "mpr.dll" _
 Alias "WNetGetConnectionA" (ByVal lpszLocalName As String, _
 ByVal lpszRemoteName As String, cbRemoteName As Long) As Long

Sub ShowMappedDrivePath()
    Dim Buffer As String * 255
    Dim BuffSize As Long
    BuffSize = 255
    If WNetGetConnection("G:", Buffer, BuffSize) = 0 Then
        MsgBox Left(Buffer, InStr(1, Buffer, Chr(0)) - 1)
    End If
End Sub

--
Jim Rech
Excel MVP



Mon, 04 Jul 2005 21:29:30 GMT  
 Find which server user is logged onto
Hi Denise

Go to www.mvps.org/vb/, click on the "Samples" link and scroll down until
you come to the UncName.zip section. Download that file and unzip it. Import
the UncName.bas module into your project. It will give you a GetUncName
function which will turn a drive-based pathname into a UNC-based pathname.

Although the samples on www.mvps.org/vb/ are mostly written in VB5 or VB6,
many of them can be imported into VBA unmodified.

--
Regards
Jonathan West - Word MVP
MultiLinker - Automated generation of hyperlinks in Word
Conversion to PDF & HTML
http://www.multilinker.com
Word FAQs at http://www.multilinker.com/wordfaq
Please post any follow-up in the newsgroup. I do not reply to Word questions
by email


Quote:
> Hello

> Using Office 97, SR-2 on Windows 2000 V5.0, SP-3.

> As part of an Excel template I've been working on, one of the pieces of
> information I need is the full path to the server that the user is
currently
> connected to.  I tried using the ActiveWorkbook.Path property, but this
gave
> me the drive mapping rather than the full path including server name.

> Is there a relatively easy way to get this information?  It would really
be
> most useful to my application.

> Many thanks in advance

> Denise Crawley



Mon, 04 Jul 2005 21:47:57 GMT  
 Find which server user is logged onto
Many thanks to both you and Jim for your prompt responses.  I imported the
UncName module and it worked a treat.  Thanks also to Karl Peterson,
wherever you may be, for writing the code!

Phew - you've saved me a lot of time and a LOT of grief!

Denise Crawley


Quote:
> Hi Denise

> Go to www.mvps.org/vb/, click on the "Samples" link and scroll down until
> you come to the UncName.zip section. Download that file and unzip it.
Import
> the UncName.bas module into your project. It will give you a GetUncName
> function which will turn a drive-based pathname into a UNC-based pathname.

> Although the samples on www.mvps.org/vb/ are mostly written in VB5 or VB6,
> many of them can be imported into VBA unmodified.

> --
> Regards
> Jonathan West - Word MVP
> MultiLinker - Automated generation of hyperlinks in Word
> Conversion to PDF & HTML
> http://www.multilinker.com
> Word FAQs at http://www.multilinker.com/wordfaq
> Please post any follow-up in the newsgroup. I do not reply to Word
questions
> by email



> > Hello

> > Using Office 97, SR-2 on Windows 2000 V5.0, SP-3.

> > As part of an Excel template I've been working on, one of the pieces of
> > information I need is the full path to the server that the user is
> currently
> > connected to.  I tried using the ActiveWorkbook.Path property, but this
> gave
> > me the drive mapping rather than the full path including server name.

> > Is there a relatively easy way to get this information?  It would really
> be
> > most useful to my application.

> > Many thanks in advance

> > Denise Crawley



Mon, 04 Jul 2005 23:28:25 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Using VBScript to find out who is logged onto remote machines/domains

2. Current User Logged onto Workstation

3. Which user is logged onto Workstation?

4. Determine whether user has logged onto network

5. Checking if user is logged onto the Internet

6. logging a user onto Windows NT programatically

7. Which machine a user is logged onto

8. VB code to list users logged onto a domain

9. Solved: Log onto MS SQL Server at runtime using OLEDB

10. Logging onto a server

11. How do i make a server program that will log and log off other users

12. Programmatically kill user connection/log user off server.

 

 
Powered by phpBB® Forum Software