Questions about user authentication in my application

Hi, all,

I am a newbie to linux authentication part.

Questions below really puzzle me:

[1] How to authenticate users from local storage(passwd shadow) and nis server?
(Without PAM)
getpwnam_r() will return a '*' in the pw_passwd field of "struct passwd".

I can parse /etc/shadow. But how can I do it on nis server? in my env, shadow file only contains local user info.

PLUS, how to maintain the session without PAM?

I have some experience in web development. There r some structure we can use to maintain the session. How to do it in a C/S design?

[2] Use pam to authenticate them.

My application is a c/s design. Suppose client needs to send the username/passwd to server with some tcp/udp pakages. Server uses pam to get it authenticated.

How to fulfill this?

Any examples? what if the client has a GUI? including for pam.d/my_application?

some pseudo codes will do.

Thanks a million.

bump bump bump