Mombu the Programming Forum sponsored links

Go Back   Mombu the Programming Forum > Programming > LogonUser SHBrowseForFolder Problem
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 18th November 22:48
as_megas
External User
 
Posts: 1
Default LogonUser SHBrowseForFolder Problem



Hi,

I've got a function that tries to select a directory under a network
shared folder. Here is what I did :

bool __fastcall BrowseForFolder(WideString Title, WideString &Path)
{

BROWSEINFO BrowsingInfo;
wchar_t DirPath[MAX_PATH];
LPITEMIDLIST ItemID;

memset(&BrowsingInfo, 0, sizeof(BROWSEINFO));
memset(DirPath, 0, MAX_PATH);
BrowsingInfo.hwndOwner = GetActiveWindow();
BrowsingInfo.lpszTitle = Title.c_bstr();
BrowsingInfo.ulFlags |= BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS
| BIF_SHAREABLE | BIF_USENEWUI | BIF_BROWSEINCLUDEFILES |
BIF_BROWSEINCLUDEURLS ;

if(Path != NULL)
{
// namespace root for parsing the path
LPSHELLFOLDER psfDesktop = NULL;
SHGetDesktopFolder(&psfDesktop);
// parse path for absolute PIDL, and connect to target folder
LPITEMIDLIST pidl = NULL; // general purpose
psfDesktop->ParseDisplayName(NULL, NULL, Path.c_bstr(), NULL, &pidl,
NULL);
BrowsingInfo.pidlRoot = pidl;
}
CoInitialize(NULL);
ItemID = SHBrowseForFolder(&BrowsingInfo);
if(ItemID)
{
SHGetPathFromIDList(ItemID, DirPath);
Path=WideString(DirPath);
}
GlobalFreePtr(ItemID);
return 0!=ItemID;

}


void main(void)
{
WideString Directory;

HANDLE token;
if(LogonUser(EditLogin->Text.c_bstr(), L"\\\\192.168.0.2",
EditPassword->Text.c_bstr(),
LOGON32_LOGON_NEW_CREDENTIALS,
LOGON32_PROVIDER_DEFAULT,
&token))
{
if(ImpersonateLoggedOnUser(token))
{
Directory = "\\\\192.168.0.2\\directory1\\subdirectory";
if(BrowseForFolder(WideString("Please select the directory"),
Directory))
EditServerPath->Text = Directory;

RevertToSelf();
}
CloseHandle(token);
}
else
MessageDlg("Impossible to connect to Server !", mtWarning,
TMsgDlgButtons() << mbOK, 0);
}

My problem is that it succeeds to show the directory
\\\\192.168.0.2\\directory1\\subdirectory, but I can't see anything
under it (neither subdirectories, nor files). What am I doing wrong ?

Further more, if I log onto the server with an explorer, and than I try
to launch my code, It succeeds in listing all the subdirectories and
files under de path !

Has anyone encountered such problems ?

Thanks a lot for your attention.
  Reply With Quote


  sponsored links


Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666