Solved

using createdirectory API fcn

Posted on 2003-12-09
6
302 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 8

Expert Comment

by:gmayo
ID: 9910699
0
 
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

Independent Software Vendors: 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

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

710 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