Solved

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

Posted on 2004-03-24
6
1,250 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
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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Word Pro Conversion utility 13 34
Lotus Notes Calendar Issue 5 110
IBM Domino web server 5 64
Lotus Notes Calendar Help 6 99
You’ve got a lotus Domino web server, and you have been told that “leverage browser caching” is a must do. This means that we have to tell the browser everywhere in the web to use cache. In other words, we set (and send) an expiration date in the HT…
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.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

776 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