[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2004-03-24
6
Medium Priority
?
1,261 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Lack of Storage capacity is a common problem that exists in every field of life. Here we are taking the case of Lotus Notes Emails, as we all know that we are totally depend on e-communication i.e. Emails. This article is fully dedicated to resolvin…
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 course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

656 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