?
Solved

How to get Active Directory's Login User Name from Lotus Notes?

Posted on 2004-03-24
6
Medium Priority
?
1,257 Views
Last Modified: 2013-12-18
Hi all,

I have a problem to generate a text file to the user's local "C:\Temp" folder.
I have this program (in Lotus Scripts), to generate a text file from a Notes document to the user's local C drive.

However, the user is logging into network using Active Directory. So the AD doesn't allow my program to write the text file into the "C:\Temp" folder.

So, I'm thinking that to write the text file into the user's "login" folder ("C:\My documents\UserName.UserDomain\Temp\" folder).

Is there any ways for me to get the user's AD login folder (ie. the "UserName.UserDomain") in my LotusScripts program?

Thanks very much in advance.

~kspuea
0
Comment
Question by:kspuea
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 5

Expert Comment

by:pgloor
ID: 10675884
Try the following function to get the users MyDocuments folder. I used this with Windows ME. Not sure it works for other Windows systems and AD.

Peter
--------------------------------------------------------------------------------
Option Public
Option Declare

Declare Function SHGetSpecialFolderPath Lib "shell32.dll" Alias "SHGetSpecialFolderPathA" _
(Byval hWnd As Long, Byval lpszPath As String, Byval nFolder As Integer, Byval fCreate As Integer) As Integer

' This are the constants nFolder accepts
' We will only use CSF_PERSONAL. You can remove all others
Private Const CSF_DESKTOP = &H0
Private Const CSF_INTERNET = &H1
Private Const CSF_PROGRAMS = &H2
Private Const CSF_CONTROLS = &H3
Private Const CSF_PRINTERS = &H4
Private Const CSF_PERSONAL = &H5      ' MyDocuments folder
Private Const CSF_FAVORITES = &H6
Private Const CSF_STARTUP = &H7
Private Const CSF_RECENT = &H8
Private Const CSF_SENDTO = &H9
Private Const CSF_BITBUCKET = &HA
Private Const CSF_STARTMENU = &HB
Private Const CSF_DESKTOPDIRECTORY = &H10
Private Const CSF_DRIVES = &H11
Private Const CSF_NETWORK = &H12
Private Const CSF_NETHOOD = &H13
Private Const CSF_FONTS = &H14
Private Const CSF_TEMPLATES = &H15
Private Const CSF_COMMON_STARTMENU = &H16
Private Const CSF_COMMON_PROGRAMS = &H17
Private Const CSF_COMMON_STARTUP = &H18
Private Const CSF_COMMON_DESKTOPDIRECTORY = &H19
Private Const CSF_APPDATA = &H1A
Private Const CSF_PRINTHOOD = &H1B
Private Const CSF_ALTSTARTUP = &H1D
Private Const CSF_COMMON_ALTSTARTUP = &H1E
Private Const CSF_COMMON_FAVORITES = &H1F
Private Const CSF_INTERNET_CACHE = &H20
Private Const CSF_COOKIES = &H21
Private Const CSF_HISTORY = &H22

Public Function GetMyDocumentsFolder() As String
      ' Returns the users MyDocuments folder
      Dim ret As Long
      Dim strBuf As String
      
      ' Prepare the buffer to receive up to 512 bytes from API call      
      strBuf = Space$(512)
      ' Get the folder
      ret = SHGetSpecialFolderPath(0, strBuf,  CSF_PERSONAL, False)
      
      ' The API returns a zero-terminated string
      ' Remove anything from chr(0) on      
      ret = Instr(strBuf, Chr$(0))
      If ret > 1 Then
            GetMyDocumentsFolder = Left$(strBuf, ret - 1)
      Else
            GetMyDocumentsFolder = ""
      End If      
End Function

Sub Initialize
  ' GetMyDocumentsFolder() returns a String with the path to the folder
  Print GetMyDocumentsFolder()
End Sub


0
 
LVL 24

Assisted Solution

by:HemanthaKumar
HemanthaKumar earned 80 total points
ID: 10677239
Use Environment variable called temp , this will return user temp directory. How to do it in LS ??

Here is the method

tempdir = Environ("Temp")

~Hemanth
0
 

Author Comment

by:kspuea
ID: 10684489
Hi pgloor, Hemanth,

Maybe I did make my question clear.
What I want to achieve is, to get the User's personal directory after they login into network.

How the AD works in our network is like this:
- When a user logins into network, the whole local C:\ drive is hidden, the user can't write anything to any folders.
- However, each user will have their personal folder (called "C:\Documents and Settings\UserName.UserDomain\") after they login into network.
- The "UserName" is their login User ID to the network.

So, my question is, can I get the current login "UserName" & "UserDomain" from the OS (or anywhere), so that my program can write text file into their personal folder (since the whole C:\ drive is hidden).

Thanks very much in advance.

~kspuea
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 15

Accepted Solution

by:
Bozzie4 earned 200 total points
ID: 10684795
It's the same for UserName and UserDomain :

adUserName = Environ( "USERNAME" )
adDomain = Environ( "USERDOMAIN" )
homeDrive = Environ( "HOME" ) ' not to sure about this one :-)

Tom
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 10687431
There you go.. environ for rescue..!
0
 
LVL 19

Assisted Solution

by:RanjeetRain
RanjeetRain earned 120 total points
ID: 10702171
Environ is enough. This will do the trick for you. You may use the following variables:

HOMEDRIVE
HOMEPATH
TEMP
TMP
USERDNSDOMAIN
USERDOMAIN
USERNAME

Username and User Domain may not always help you generate the correct path. My recommendation is to use this:

HOMEDRIVE = Environ("HOMEDRIVE")
HOMEPATH = Environ("HOMEPATH")
FULLPATH = HomeDrive + HomePath

Now save your file under FULLPATH.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For Desktop Techs: How to retain a user's Notes configuration data when swapping out the end user's computer. (Assuming that you are not upgrading to a completely different version of Notes client) All you need to do is: 1) install Notes o…
  In today’s Arena we can’t imagine our lives without Internet as we are highly used to of it. If we consider our life style just for only 2 min we found that face to face communication is swapped by e-communication.  Every Where from Works place to…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month9 days, 5 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question