Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Set Folder/File Permission from AX

107 views
Skip to first unread message

YW

unread,
Dec 14, 2009, 2:37:01 AM12/14/09
to
We have to set folder and file permission while creating from AX for
different persons.
Is it possible?

fileIOPermission = new FileIOPermission(fileName, 'w'); --> set only global
permission.

We didn't find the code for:
- setting folder permission
- setting file/folder permission per group/person

Thanks in advance for helping us!

Axel Kühn

unread,
Dec 14, 2009, 3:30:01 AM12/14/09
to
Hi,
yes it is possible to set the file/folder permissions from AX.
You have to use some classes of the .NET Framework to handle this.

There are several ways in .NET how you can do this.

Please take a look at these articles describing some of the ways (incl.
sample code):
http://support.microsoft.com/kb/899553
http://www.redmondpie.com/applying-permissions-on-any-windows-folder-using-c/
http://weblogs.asp.net/cumpsd/archive/2004/02/08/69403.aspx
http://mikevandermeulen.com/Blog/tabid/55/EntryId/15/Setting-File-Folder-Permissions-in-C.aspx

Hope this helps you.
--
Sincerely yours
Axel Kühn (visit my Dynamics AX blog at: http://blog.ak-home.net)

YW

unread,
Dec 16, 2009, 9:58:02 AM12/16/09
to
Hi

thanks for your links. I'm really sorry, but we do not have the know how to
call these .NET codes from AX. Could you get us an example?

thank you!

best regards

YW

unread,
Dec 16, 2009, 9:59:01 AM12/16/09
to
hi

Thank you for your links. unfortunately we do not have the know how calling
.net codes from ax. could you please get us an example?

thank you.

best regards.
YW

Axel Kühn

unread,
Dec 16, 2009, 3:43:01 PM12/16/09
to
Hi,

currently i have no sample code/example on hand which fits to your needs.
Sorry about that.

But each Link provides also some sample code demonstrating the things.

Axel Kühn

unread,
Dec 18, 2009, 5:25:01 AM12/18/09
to
Please take a look at this article:
http://translate.google.com/translate?client=tmpg&hl=de&u=http%3A%2F%2Fblog.ak-home.net%2FPermaLink%2Cguid%2Ca2a673b5-22eb-430f-8d46-ef38a5f28169.aspx&langpair=de|en

The sample code create a outlook appointment over .Net.
The sample code is fully witten in AX.

YW

unread,
Jan 11, 2010, 5:22:01 AM1/11/10
to
solution:

void setAccess(str _root, str _LstrFolder)
{
//Directory
System.Security.AccessControl.DirectorySecurity dirSecurity;
System.IO.DirectoryInfo dirInfo;

//File
System.Security.AccessControl.FileSecurity fileSecurity;
System.IO.FileInfo fileInfo;

//Access rights and user identification
System.Security.AccessControl.FileSystemAccessRule accessRule;
System.Security.AccessControl.FileSystemRights fileSystemRights;
System.Security.AccessControl.InheritanceFlags inheritanceFlags;
System.Security.AccessControl.PropagationFlags propogationFlags;
System.Security.AccessControl.AccessControlType accessControlType;

UserInfo UserInfo;
SHRDocuFolder LtabSHRDocuFolder;
;

dirInfo = new System.IO.DirectoryInfo(_root);

// Get a DirectorySecurity object that represents the current security
settings.
dirSecurity = dirInfo.GetAccessControl();

// Add the FileSystemAccessRule to the security settings.
//identity = "Domain\\Name";

fileSystemRights = System.Security.AccessControl.FileSystemRights::Write;
//:Write;

inheritanceFlags =
System.Security.AccessControl.InheritanceFlags::ObjectInherit;

propogationFlags =
System.Security.AccessControl.PropagationFlags::NoPropagateInherit;

accessControlType = System.Security.AccessControl.AccessControlType::Allow;

accessRule = new
System.Security.AccessControl.FileSystemAccessRule(identity,
fileSystemRights, inheritanceFlags, propogationFlags, accessControlType);

//set directory access
dirSecurity.AddAccessRule(accessRule);

// Set the new directory access settings.
dirInfo.SetAccessControl(dirSecurity);

}

0 new messages