Discussion:
Setting NTFS file system folder permissions in VS2005
(too old to reply)
Bragadiru
2005-12-14 15:22:01 UTC
Permalink
Hi all,

I used ADSI for to programmatically set NTFS file system folder permissions
by using Active Directory Service Interfaces in Microsoft Visual C#
2002/2003 (http://support.microsoft.com/kb/899553/EN-US). I need the same
thing in VS 2005 / .NET Framework 2.0, but after I add references to Active
DS Type Library and ADsSecurity 2.5 (both COM objects), I'm getting a lot of
warnings at compile time, like :

Warning : The type library importer could not convert the signature for the
member 'ADS_OCTET_STRING.lpValue'.
...
Warning : At least one of the arguments for
'IPrivateDispatch.ADSIGetIDsOfNames' cannot be marshaled by the runtime
marshaler. Such arguments will therefore be passed as a pointer and may
require unsafe code to manipulate. DBCustomAction
...

And I cannot get ride of those warnings. Am I using the right versions ??
There is another KB article about this pb and Visual Studio 2005 ?
With all this warnings it seems it still works, but very, very slow. Any
ideea why ?

I have a Windows XP + sp2 + VS 2005.

Thanks for any advice.
Jeffrey Tan[MSFT]
2005-12-15 06:44:17 UTC
Permalink
Hi Bragadiru,

Thanks for your post.

I am not sure what system you are using. On my Win2003 machine, I first
download and installed the ADSI SDK from the link below:
http://download.microsoft.com/download/2/9/7/29720925-faa3-477f-a5cd-beef80a
dac07/adsrtk.msi
(this is just the "Download the SDK for Active Directory Services
Interfaces 2.5 (English Language Version)" link in page
http://www.microsoft.com/ntserver/nts/downloads/other/ADSI25/default.asp)

Then, I go to C:\Program Files\Microsoft\ADSI Resource Kit, Samples and
Utilities\ResourceKit folder to register ADsSecurity.dll with command line
below:
regsvr32 ADsSecurity.dll

Then in VS2005 "Add Reference" dialog, I can see the "ADsSecurity 2.5 Type
Library" in COM tabpage and reference it.

After above steps, I can paste the KB code and compile it without any
warning message. So can not confirm you did the above prerequest correctly?
Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Bragadiru
2005-12-15 15:07:23 UTC
Permalink
Hi Jeffrey,

I installed VS 2005 Team Solution for Developers on a clean new machine with
Windows XP Pro + SP2. No previous beta/rc versions of .NET.

I followed ALL the steps from kb article + registered properly the
AdsSecurity.dll and still getting 39 warnings like :

Warning 8 The type library importer could not convert the signature for the
member 'ADS_OCTET_STRING.lpValue'. WindowsApplication2

Warning 9 The type library importer could not convert the signature for the
member '__MIDL___MIDL_itf_ads_0000_0002.lpValue'. WindowsApplication2

Warning 10 The type library importer could not convert the signature for the
member 'ADS_NT_SECURITY_DESCRIPTOR.lpValue'. WindowsApplication2

...

Warning 32 At least one of the arguments for
'IPrivateDispatch.ADSIGetIDsOfNames' cannot be marshaled by the runtime
marshaler. Such arguments will therefore be passed as a pointer and may
require unsafe code to manipulate. WindowsApplication2

Warning 33 At least one of the arguments for 'ITypeInfo.RemoteGetTypeAttr'
cannot be marshaled by the runtime marshaler. Such arguments will therefore
be passed as a pointer and may require unsafe code to manipulate.
WindowsApplication2

...

Thanks
Post by Jeffrey Tan[MSFT]
Hi Bragadiru,
Thanks for your post.
I am not sure what system you are using. On my Win2003 machine, I first
http://download.microsoft.com/download/2/9/7/29720925-faa3-477f-a5cd-beef80a
dac07/adsrtk.msi
(this is just the "Download the SDK for Active Directory Services
Interfaces 2.5 (English Language Version)" link in page
http://www.microsoft.com/ntserver/nts/downloads/other/ADSI25/default.asp)
Then, I go to C:\Program Files\Microsoft\ADSI Resource Kit, Samples and
Utilities\ResourceKit folder to register ADsSecurity.dll with command line
regsvr32 ADsSecurity.dll
Then in VS2005 "Add Reference" dialog, I can see the "ADsSecurity 2.5 Type
Library" in COM tabpage and reference it.
After above steps, I can paste the KB code and compile it without any
warning message. So can not confirm you did the above prerequest correctly?
Thanks
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Jeffrey Tan[MSFT]
2005-12-16 08:10:13 UTC
Permalink
Hi Bragadiru,

Thanks for your feedback.

I have tried to test this issue on my colleage's machine, which is WinXP
SP2 OS, with VS2005 installed. However, after installing the ADSI SDK msi
file, and registering the ADsSecurity.dll. I can compiling the KB article
code without any warnings.(I use VS2005 to create a new project and copy
the KB code snippet in)

Currently, I suggest you try the steps on some other machines, if the
warnings still arise.(It at least does not occur on my 2 tested machines).
Then we can determine if this issue is machine or OS specific.

Because the KB only uses COM interop to manipulate ADSI, you can also try
the KB in VS.net2003 as a test.

Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Bragadiru
2005-12-16 16:11:43 UTC
Permalink
Thanks for your response.

It's obvious for me that my WinXp machine has something wrong, even I
started installing everything from 0.
I don't even need to write 1 line of code to get those 39 warnings. I just
add a reference to ActiveDs COM object and "using ActiveDs;" at the
begining.
My COM reference ActiveDs Type Library resides on
C:\WINDOWS\system32\activeds.tlb, version 5.1.2600.0 (xpclient.010817-1148).
In the same folder I have an activeds.dll file version 5.1.2600.2180
(xpsp_sp2_rtm.040803-2158). Is it ok ?

Thanks a lot
Post by Jeffrey Tan[MSFT]
Hi Bragadiru,
Thanks for your feedback.
I have tried to test this issue on my colleage's machine, which is WinXP
SP2 OS, with VS2005 installed. However, after installing the ADSI SDK msi
file, and registering the ADsSecurity.dll. I can compiling the KB article
code without any warnings.(I use VS2005 to create a new project and copy
the KB code snippet in)
Currently, I suggest you try the steps on some other machines, if the
warnings still arise.(It at least does not occur on my 2 tested machines).
Then we can determine if this issue is machine or OS specific.
Because the KB only uses COM interop to manipulate ADSI, you can also try
the KB in VS.net2003 as a test.
Thanks
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Jeffrey Tan[MSFT]
2005-12-20 07:58:03 UTC
Permalink
Hi Bragadiru,

Thanks for your feedback.

Yes, I think your version should be OK. Because the activeds.tlb and
activeds.dll will have the same version information below:
5.1.2600.0 (xpclient.010817-1148)
and
5.1.2600.2180 (xpsp_sp2_rtm.040803-2158)

So I do not think this is caused by the different dll version.

Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Continue reading on narkive:
Loading...