Authenticate from C program

Adam Siegel agsiegel at gmail.com
Wed May 6 20:41:50 GMT 2009


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.
-------------- next part --------------
HTML attachment scrubbed and removed


More information about the smb-clients mailing list