示例#1
0
        public static void Main(string[] args)
        {
            Console.Write("Username: "******"START - SUCCESS!");
                    retval = mySession.Authenticate(0);
                    if (retval == PamStatus.PAM_SUCCESS)
                    {
                        Console.WriteLine("AUTHENTICATION - SUCCESS!");
                        retval = mySession.AccountManagement(0);
                        if (retval == PamStatus.PAM_SUCCESS)
                        {
                            Console.WriteLine("ACCESS - SUCCESS!");
                        }
                        else
                        {
                            Console.WriteLine("ACCESS - Failure: {0}", retval);
                        }
                    }
                    else
                    {
                        Console.WriteLine("AUTHENTICATION - Failure: {0}", retval);
                    }
                }
                else
                {
                    Console.WriteLine("START - Failure: {0}", retval);
                }
            }
        }
示例#2
0
        public void TestFailForBadUser()
        {
            long   start   = DateTime.Now.Ticks;
            IntPtr appData = Marshal.AllocHGlobal(Marshal.SizeOf <long>());

            Marshal.WriteInt64(appData, 0, start);

            NpamSession session = null;

            using (session = new NpamSession(NpamTestsCommon.TestService, NpamTestsCommon.TestUsernameBad, ConvHandler, appData)) {
                Assert.Equal(PamStatus.PAM_SUCCESS, session.Start());
                Assert.Throws <InvalidOperationException>(() => { session.Start(); });
                Assert.Equal(PamStatus.PAM_AUTH_ERR, session.Authenticate(0));
                Assert.Equal(PamStatus.PAM_AUTH_ERR, session.AccountManagement(0));
            }
            Assert.Throws <InvalidOperationException>(() => { session.AccountManagement(0); });
        }