anybody has experience with COAUTHIDENTITY?
I can't seem to get the values correct :(
My code is shown below:
ZeroMemory(&coAuthIdentity, sizeof(coAuthIdentity));
coAuthIdentity.Password = (unsigned short*)"password";
coAuthIdentity.Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE;
coAuthIdentity.User = (unsigned short*)"hfyap";
coAuthIdentity.UserLength = 4;
cout<<coAuthIdentity.User<<endl;
cout<<coAuthIdentity.Password<<endl;
When it prints out, I get 0043F46C and 0043F460 no matter what kind of
values I put in.
What I want to create is to make the OPC server and client connect to
each other remotely. I have been having problems configuring this on
winxp sp2 even after following the white paper on changing the dcom
configs so i figured that I'd try to create same local user accounts on
the pcs that the server and client are situated (They are not in any
domain). That means I have to use COAUTHIDENTITY correct?
Btw, in dcomcnfg, when I set the properties for the OPC server, I chose
connect for authentication level and user as eg. pc_name\local_user. On
the OPC client side, I also chose connect for authentication lvl, user
as eg. pc_name2\local_user.
I have practically gave access and launch permissions, both locally and
remotely to administrators, everyone, system, users, local user,
anonymous_logon on both pcs as a desperate bid to connect remotely. I
have also ensure that OPCenum, the server and client, DCOM port are
placed in exceptions in windows firewall respectively.
What am I doing wrong? I'll appreciate any help given, thanks.
Atiz
Both User and Password expect Unicode strings. Casting a regular char*
pointer to unsigned short* does not magically make the string Unicode.
Make it
coAuthIdentity.Password = L"password";
coAuthIdentity.User = L"hfyap";
wcout<<coAuthIdentity.User<<endl;
wcout<<coAuthIdentity.Password<<endl;
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
thanks for replying :D
but when I tried your method, when I compile, I will get this error:
error C2440: '=' : cannot convert from 'const wchar_t [9]' to 'USHORT
*'
Ok, so that means I have to say, do the following below:
char* username;
username = "user";
coAuthIdentity.User = L"username";
Even so, I will still get back the same error as shown above.
Atiz
Make it
coAuthIdentity.User = (USHORT*)L"username";
wcout << (wchar_t*)coAuthIdentity.User;
The structure was apparently defined back when the compiler didn't
support wchar_t as a distinct type, and Unicode characters were modelled
as unsigned shorts.
Btw, this part will be ignored if the client and server are in the same
pc correct? Will the client only use CoAuthIdentity if it is trying to
connect remotely?
Also, may I ask whether in order for the server and client to connect
remotely, in pcs with no domains, I have to set the coauthIdentity's
username and password to the local user account and the local user
account on both pcs must be the same right?
So that means, the client will try auto try to detect the server and
check that the username and password stated in coauthidentity is the
same as the local user account of the pc that server is in when client
is up?
Atiz
I believe this is the case in peer-to-peer networks, but I'm not an
expert on this. If you encounter problems, consider asking in a new,
separate thread: people tend not to see new questions buried deep in old
threads.
Yes, this is correct. Both the name and the passwords on both computers must
match.
Brian
yar I have long set the user account to be the same on both pcs but
does not seem to be working.
When you add for example, access permission, I add local user like
pc1_name/username to the server and pc2_name/username to the client
side. When the server and client tries to connect, they will not bother
about the pc's name right? They will only see the "username" that I
have set there.
I have posted another thread with more details regarding this, hope you
can help me, thanks alot!
Atiz
ps: Thx Igor!
That is correct.
Remember, you have only asked about one particular setting. There are other
dials that need to be looked at. You need to configure the COM server so
that the remote user is entitled to launch, activate and access the COM
server. Usually this is done using DCOMCNFG, but you need to check to see of
CoInitializeSecurity() is also being called with the correct parameters.
Similarly, the client may also be calling CoIntializeSecurity().
Is the server Win2003 Server SP1? If so, the user needs to be part of the
Distributed COM Users group.
Brian