LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 09-04-2002, 03:56 AM   #1
antken
Member
 
Registered: Nov 2000
Location: england
Distribution: latest Mandrake
Posts: 368

Rep: Reputation: 30
simple program big problem


hi,

i have a program that basically uses a function from samba to determin if the username and pass are valid on the given windows nt domain sadly this worked once and has since stoped working ( code snip at end of message )

when its valid it returns 0 and invalid it returns 1
the function is Valid_User (user, pass, server, backup, domain)
now from the code i can make out, the function should return a message of some sort ( am i right? ) i would like to print/echo on the screen any information given out from the vailid_user function
how would i go about doing this should i read it in to a varible first then put that on screen or can i take it directly from the function?

i am a bit of a newbie at the so please could you explain as much as you can

please please could some one help me ?!
thanks
ant ken

Code:
--------------------------------------------------
#include <stdio.h>
#include "valid.h"

int main(int argc, char ** argv)
{
char * user, * pass, * server, * backup, * domain;

if(argc < 6)
return 1;

user = argv[1];
pass = argv[2];
server = argv[3];
backup = argv[4];
domain = argv[5];


if(Valid_User(user, pass, server, backup, domain) == NTV_NO_ERROR)
return 0;

return 1;
}
------------------------------------------ end code

Last edited by antken; 09-04-2002 at 03:57 AM.
 
Old 09-04-2002, 07:51 AM   #2
no2nt
Member
 
Registered: Aug 2001
Location: South Carolina, USA
Distribution: Redhat 8.0/Custom
Posts: 96

Rep: Reputation: 16
line 6:
Code:
int ret;
line 19:
Code:
if( (ret = Valid_user(user,pass,server,backup,domain)) == NTV_NO_ERROR)
{
    printf("return code: %d\n", ret);
    return 0;
}
else
{
    printf("return code (on error): %d\n", ret);

/* or
switch(ret)
{
    case NTV_BAD_PASSWORD: // possibly defined in valid.h
    {
        printf("NTV_BAD_PASSWORD\n");
        break;
    }
}
*/
return 1;
}
maybe something like that? I am assuming that valid.h has defines for
NTV_NO_ERROR and such. You could use a switch statement on ret
to print out exact error messages.

Last edited by no2nt; 09-04-2002 at 07:53 AM.
 
Old 09-05-2002, 03:12 AM   #3
antken
Member
 
Registered: Nov 2000
Location: england
Distribution: latest Mandrake
Posts: 368

Original Poster
Rep: Reputation: 30
cheers thanks,



thats a big help


i have looked around in valid.c and found the error 'codes' ( if you like )

i have re-written the program slightly and figured out that the Samba is having trouble with connecting to the server thats why its failing but i am now unsure if its a config error in samba or if its something else
 
Old 09-15-2002, 10:39 AM   #4
antken
Member
 
Registered: Nov 2000
Location: england
Distribution: latest Mandrake
Posts: 368

Original Poster
Rep: Reputation: 30
i have now got the program working again thanks for your help on that.


now i would like to expand on the program and make it write a log to a file every time a user provides a bad username or password

for example in the log it would say something like:
login for userx failed @ {time} {date}


I am new to this language, so how would i go about writing/appending to a file and constructing the string of text that would go in there?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SDL problem... simple program. RHLinuxGUY Programming 1 07-22-2005 06:04 PM
simple problem to a big issue avimd Linux - Laptop and Netbook 1 06-25-2005 06:33 AM
simple C program problem speel Programming 14 02-27-2005 05:08 PM
Simple router but big problem Rajahuroman Linux - Networking 6 08-13-2004 08:43 AM
simple C program problem mined Programming 2 05-08-2004 05:42 AM


All times are GMT -5. The time now is 05:43 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration