Solved

using createdirectory API fcn

Posted on 2003-12-09
6
309 Views
Last Modified: 2010-04-05
I want to be able to create users home directories on a sever from an application.

Given the username the app should create the home folder using the username as the folder name.the folder should have the following perms

1)administrators-FC
2) username-FC
3) folder should not inherit perms from parent folder

0
Comment
Question by:mem100
[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 17

Expert Comment

by:geobul
ID: 9910718
Hi,

For creating the directory use ForceDirectories function from FileCtrl unit.

For sharing it and giving premissions you'll need NetShareAdd and NetShareSetInfo API functions. Look at this question:
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20166800.html

Regards, Geo
0
 
LVL 17

Expert Comment

by:geobul
ID: 9910747
0
 

Author Comment

by:mem100
ID: 9976111
found solution.

 it requires  Win32 headers from www.delphi-jedi.org

procedure TForm1.Button1Click(Sender: TObject);
var
    securityAttr:TSecurityAttributes;
    lpsecuritydesc:JwaWinNT.PSecurityDescriptor; // PSecurityDescriptor is also defined in windows.pas
    ea:array[0..1] of TExplicitAccessW;
    easize:integer;
    pacl:JwaWinNT.PACL;// PACL is also defined in windows.pas

begin

ea[0].grfAccessPermissions:= STANDARD_RIGHTS_ALL or SPECIFIC_RIGHTS_ALL;
ea[0].grfAccessMode:=SET_ACCESS;
ea[0].grfInheritance:=SUB_CONTAINERS_AND_OBJECTS_INHERIT;
ea[0].Trustee.TrusteeForm:=TRUSTEE_IS_NAME;
ea[0].Trustee.TrusteeType:=TRUSTEE_IS_USER;
ea[0].Trustee.ptstrName:='mark-wks\markm';

ea[1].grfAccessPermissions:= STANDARD_RIGHTS_ALL or SPECIFIC_RIGHTS_ALL;
ea[1].grfAccessMode:=SET_ACCESS;
ea[1].grfInheritance:=SUB_CONTAINERS_AND_OBJECTS_INHERIT;
ea[1].Trustee.TrusteeForm:=TRUSTEE_IS_NAME;
ea[1].Trustee.TrusteeType:=TRUSTEE_IS_GROUP;
ea[1].Trustee.ptstrName:='Administrators';

SetEntriesinAclW(2,@ea,nil,pacl);

lpsecuritydesc:= Allocmem(sizeof(SECURITY_DESCRIPTOR_MIN_LENGTH));
InitializeSecurityDescriptor(lpsecuritydesc,SECURITY_DESCRIPTOR_REVISION);
SetSecurityDescriptorDacl(lpsecuritydesc,true,pacl,false);

FillChar(securityattr,sizeof(SECURITY_ATTRIBUTES),#0);
securityattr.nLength:=sizeof(SECURITY_ATTRIBUTES);
securityattr.lpSecurityDescriptor:=lpsecuritydesc;
securityattr.bInheritHandle:=false;

if createdirectory('\\mark-wks\home\markm',@securityattr) then
 showmessage('folder created')
else showmessage('error creating folder');

hope it helps someone
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 13056299
PAQed with points refunded (500)

modulo
Community Support Moderator
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month11 days, 17 hours left to enroll

623 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