I am developing a web server in ASP.NET.
There are 2 web services in it. I have a C++ (unmanaged)
Library whose functions are being called from my C# code
with DLLIMPORT attribute.

Problem:

My C++ library has two functions. Both of them are opening
sockets using Winsock.

One function is opening socket
like
(1)
sockRaw = WSASocket(AF_INET,SOCK_RAW,IPPROTO_ICMP,NULL,0
,WSA_FLAG_OVERLAPPED);

and the other function is
(2)
m_Socket = socket(AF_INET, SOCK_STREAM, 0);




I login to my this site from different machine in same
network domain(LAN). I login with my windows user ID and
password of that system. I am able to login with
administrative rights as well as with user rights. All the
users are of the system where the webserver is running.

My problem is :

When I login with normal user ID password API (1) is
failing, I am not able to debug this code. But it is
failing. Whereas in case of administrator every thing is
working fine.
Or in other word I would say that WSASocket is failing in
to create socket because of insufficient user rights.

This is very strange for me , I don't know how it is
happening so kindly help me or suggest me what I should do.

IIS settings:
I set my Directory security to Basic Authentication.

System:
I am using
WINDOWS 2000 service pack 3
IIS 5.0
Dot net 2002 with Framework 1.1.

Thanks in advance

abhijeet

Re: not able to create socket ,coz of insufficient user rights by Abhijeet

Abhijeet
Fri Aug 08 03:23:19 CDT 2003

Thanks Cris,
Thanks for your quick and valuable information ,
My Answers
1. I already have an old DLL which does many things
including Ping , the ping function is openning Raw
socket.
2. That code is old C++ code (unmanaged).

I have three questions:

1. Is is possible to ping systems in same network domain
(LAN) without using RAw Sockets?
2. I am open to rewrite my ping specific code in C# but
tell me how to host it ? How will I make it Out process ?

3. What benifit I will get if I port my C++ code to C#
code in terms of performance and bugs.

Socket is in System.Net.Sockets Namespace not in
System.Web assembly.

Thanks in advance
-abhijeet


>-----Original Message-----
>By default, non-administrative users do not get to open
raw sockets. It's a
>very dangerous operation. Since IIS is using Basic
Authentication, it is
>launching any child processes using the domain
credentials of the user who
>authenticated, which is why it didn't work. If you need
them to work, you'll
>need to host them in a process which has the appropriate
credentials.
>
>Two questions: why do you need raw sockets, and why do
you need unmanaged
>code when you have the system.web.sockets namespace?
>
>--
>Chris Jackson
>Software Engineer
>Microsoft MVP - Windows XP
>Windows XP Associate Expert
>--
>"Abhijeet" <abhijeetgupta@tataelxsi.co.in> wrote in
message
>news:0de801c35cce$b39dfdc0$a101280a@phx.gbl...
>>
>> I am developing a web server in ASP.NET.
>> There are 2 web services in it. I have a C++ (unmanaged)
>> Library whose functions are being called from my C# code
>> with DLLIMPORT attribute.
>>
>> Problem:
>>
>> My C++ library has two functions. Both of them are
opening
>> sockets using Winsock.
>>
>> One function is opening socket
>> like
>> (1)
>> sockRaw = WSASocket(AF_INET,SOCK_RAW,IPPROTO_ICMP,NULL,0
>> ,WSA_FLAG_OVERLAPPED);
>>
>> and the other function is
>> (2)
>> m_Socket = socket(AF_INET, SOCK_STREAM, 0);
>>
>>
>>
>>
>> I login to my this site from different machine in same
>> network domain(LAN). I login with my windows user ID and
>> password of that system. I am able to login with
>> administrative rights as well as with user rights. All
the
>> users are of the system where the webserver is running.
>>
>> My problem is :
>>
>> When I login with normal user ID password API (1) is
>> failing, I am not able to debug this code. But it is
>> failing. Whereas in case of administrator every thing is
>> working fine.
>> Or in other word I would say that WSASocket is failing
in
>> to create socket because of insufficient user rights.
>>
>> This is very strange for me , I don't know how it is
>> happening so kindly help me or suggest me what I should
do.
>>
>> IIS settings:
>> I set my Directory security to Basic Authentication.
>>
>> System:
>> I am using
>> WINDOWS 2000 service pack 3
>> IIS 5.0
>> Dot net 2002 with Framework 1.1.
>>
>> Thanks in advance
>>
>> abhijeet
>>
>
>
>.
>