#166058 - 2006-08-17 11:00 PM
Re: Determine Profile Path
|
sixdoubleo
Starting to like KiXtart
Registered: 2004-02-06
Posts: 118
Loc: California, US
|
Quote:
I am not sure that the .profile property is correct in any case !!!
suppose the following situation :
- a user called "userID"
- an NT workstation with NT installed in c:\winnt
- an XP workstation with XP installed in c:\windows
if the user connects on the NT workstation, usually, the profile is c:\winnt\profiles\userID. if the user connects on the XP workstation, usually, the profile is c:\documents and settings\userID.
now, suppose that a local account also called userID exist on each workstation and connects before the domain account, when the domain account connects, the profile can be c:\winnt\profiles\userid.001, c:\documents and settings\userid.<domain> or something else.
with all theses cases, i don't think that the WINNT provider gives a good answer in any cases.
to detect a user profile on a workstation, you need the user's SID and the computername. Then, look at the registry key : \\computername\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\<sid>. If this key exists, read the value ProfileImagePath and now you have the local user's profile.
Good points.
However, you must differentiate whether you're looking for the user's roaming profile or the local profile. In this particular case, BradV is looking for the roaming profile. In that case, WinNT or LDAP will return the correct roaming profile.
Now, if you're looking to know the location of the user's LOCAL profile, it seems to me you'd almost always be working within the context of the user's logon. In which case you simply use the %USERPROFILE% environment variable. It always returns the correct dirctory regardless of OS version, duplicate account names, etc.
You don't even worry about c:\winnt, c:\documents and settings, SIDs, .001's, .002's, and so on.
So if you're wanting to drop something on the current user's desktop, it's always COPY $MyShortcut %USERPROFILE%\Desktop (or whatever).
(Unless of course you're not dealing with the CURRENT user. But any time I'm dealing with profiles offline, it's always the roaming. Although I do have a desktop cleanup script for cleaning copies of unused local profiles where I used a technique similar to yours. I don't think that's what the OP wanted though. I could be wrong.)
Edited by sixdoubleo (2006-08-17 11:27 PM)
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 2220 anonymous users online.
|
|
|