Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I have developed an application in MFC,i am creating few XML file to store the data from my application,and i was suggested to save this XML files in the Active Directory
to keep them more save.So i need to use this Active Directory as a database to store the file and also to retrieve the data from the files which are saved in the Active directory.Kindly can any one guide me for this so that i can move a head with this.

Thanks in Advance.
Posted
Updated 1-Oct-12 20:59pm
v3
Comments
Rocky_Bas 24-Sep-12 23:10pm    
Hello kindly suggest me how to do this.
Richard MacCutchan 25-Sep-12 4:47am    
What do you mean by "store in the Active Directory"?
Rocky_Bas 25-Sep-12 5:17am    
I want to save few xml files and log files in the Active Directory ,so how to do it using MFC
Argonia 2-Oct-12 9:42am    
If under Active Directory you mean the folder in which your exe will be executed just use CFile (CStdioFile i think that class will do) and use only the name of the new folder. Don't use paths.This will make the new file in the same folder where your exe is located. Be careful with CFile:: modes
Rocky_Bas 2-Oct-12 22:02pm    
Hi Argonia,I didn't mean to say the directory in which my exe is executed.I mean to say windows Active directory services.

1 solution

The following code example makes the existing "C:\MyFolder" directory a public file share. Later you can set passwords to that file share and also which users can access it. Below example is taken from MSDN, you can look around for more information with the ADSI interfaces. So the idea is keep in a NTFS folder and then set AD properties. Hope this helps...



C++
IADsFileShare *pShare = NULL;
IADsContainer *pCont = NULL;
LPWSTR adsPath = L"WinNT://yourMachineName/LanmanServer";
HRESULT hr = S_OK;

hr = ADsGetObject(adsPath, IID_IADsContainer,(void**)&pCont);
if(FAILED(hr)) {goto Cleanup;}

hr = pCont->Create(CComBSTR("FileShare"), CComBSTR("Public"), (IDispatch**)&pShare);

if(FAILED(hr)) {goto Cleanup;}

hr = pShare->put_Path(CComBSTR("c:\\public"));

if(FAILED(hr)) {goto Cleanup;}

hr = pShare->SetInfo();

Cleanup:
    if(pCont) pCont->Release();
    if(pShare) pShare->Release();
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900