Solved

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

Posted on 2004-03-24
6
1,248 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 15

Accepted Solution

by:
Bozzie4 earned 50 total points
Comment Utility
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
Comment Utility
There you go.. environ for rescue..!
0
 
LVL 19

Assisted Solution

by:RanjeetRain
RanjeetRain earned 30 total points
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

This is an old article, please see an updated version of this article, located here: http://www.experts-exchange.com/articles/23619/Notes-8-5x-Windows-7-Notes-info-and-tips.html
Article by: Rob
Notes 8.5 Archiving Steps and Tips This article covers setting up a Notes archive, and helps understand some of the menu choices making setting up and maintaining a Notes archive file easier.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now