Solved

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

Posted on 2004-03-24
6
1,254 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 20 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
Industry Leaders: 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 50 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 30 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

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

Problem "Can you help me recover my changes?  I double-clicked the attachment, made changes, and then hit Save before closing it.  But when I try to re-open it, my changes are missing!"    Solution This solution opens the Outlook Secure Temp Fold…
Notes Document Link used by IBM Notes is a link file which aids in the sharing of links to documents in email and webpages. The posts describe the importance and steps to create a Lotus Notes NDL file in brief.
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

728 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