Authenticate from C program

View: New views
4 Messages — Rating Filter:   Alert me  

Authenticate from C program

by Adam Siegel :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I want to write a very simple C program that just authenticates against a Windows domain.

ie.

if (authenicate(domain, username, password))
{
    blah ....
}


I've studied the smbclient code, but still can't get my code working consistantly.

I did something like below.


    gethostname(hostname, sizeof(hostname));
    load_case_tables();
    set_global_myworkgroup(workgroup);
    set_global_myname(hostname);
    load_interfaces();
    init_names();
   
    strcpy(info.username, username);
    strcpy(info.password, password);
    info.got_pass = 1;
    info.use_kerberos = 0;
    info.signing_state = -1;
   
    cli_cm_set_credentials(&info);
   
    cli = cli_cm_open("",  "\\\\test\\path", 1);
   
    printf("cli = %i\n", cli ? 1 : 0);


smbclient works with all the same info.  My code seems to ignore the password.  If I have permissions to the target directory, then no matter what password I use, it's ok.  smbclient fails if the password is wrong. 



Re: Authenticate from C program

by Gerald Carter-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Adam Siegel wrote:

> I want to write a very simple C program that just
> authenticates against a Windows domain.

If you are joined to the domain, look at wbcAuthenticateUser()
in libwbclient.so




cheers, jerry



signature.asc (258 bytes) Download Attachment

Re: Authenticate from C program

by Adam Siegel :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Unfortunately I am using samba version 3.0.23.  It does not look like that function is available.  Thank you so much for the response!

On Wed, May 6, 2009 at 5:03 PM, Gerald Carter <jerry@...> wrote:
Adam Siegel wrote:

> I want to write a very simple C program that just
> authenticates against a Windows domain.

If you are joined to the domain, look at wbcAuthenticateUser()
in libwbclient.so




cheers, jerry



Re: Authenticate from C program

by Gerald Carter-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Adam Siegel wrote:

> Unfortunately I am using samba version 3.0.23.  It
> does not look like that function is available.  Thank
> you so much for the response!

Look at the pam_winbind.c code and grep for PAM_AUTH.
Or look at the wbcAUthenticaUser() implementation in
Samba 3.2.  You can do the same thing in 3.0 but you
will have to statically link directly against some
Samba code.




cheers, jerry
--
=====================================================================
http://www.plainjoe.org/
"What man is a man who does not make the world better?"      --Balian



signature.asc (258 bytes) Download Attachment