]> err.no Git - sope/blob - sope-ldap/samples/ldapchkpwd.m
added key/value archiving to NSExpression
[sope] / sope-ldap / samples / ldapchkpwd.m
1 /*
2   Copyright (C) 2000-2005 SKYRIX Software AG
3
4   This file is part of SOPE.
5
6   SOPE is free software; you can redistribute it and/or modify it under
7   the terms of the GNU Lesser General Public License as published by the
8   Free Software Foundation; either version 2, or (at your option) any
9   later version.
10
11   SOPE is distributed in the hope that it will be useful, but WITHOUT ANY
12   WARRANTY; without even the implied warranty of MERCHANTABILITY or
13   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
14   License for more details.
15
16   You should have received a copy of the GNU Lesser General Public
17   License along with SOPE; see the file COPYING.  If not, write to the
18   Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19   02111-1307, USA.
20 */
21
22 #import <EOControl/EOControl.h>
23 #import <NGLdap/NGLdapConnection.h>
24 #include "common.h"
25
26 int main(int argc, char **argv, char **env) {
27   NSAutoreleasePool *pool;
28   NSUserDefaults *ud;
29   NSArray        *args;
30   BOOL ok = NO;
31   
32 #if LIB_FOUNDATION_LIBRARY
33   [NSProcessInfo initializeWithArguments:argv count:argc environment:env];
34 #endif
35
36   pool = [[NSAutoreleasePool alloc] init];
37   
38   args = [[NSProcessInfo processInfo] arguments];
39   if ([args count] < 3) {
40     NSLog(@"usage: %@ <user> <password>", [args objectAtIndex:0]);
41     exit(1);
42   }
43   
44   ud = [NSUserDefaults standardUserDefaults];
45   
46   ok = [NGLdapConnection checkPassword:[args objectAtIndex:2]
47                          ofLogin:[args objectAtIndex:1]
48                          atBaseDN:[ud stringForKey:@"LDAPRootDN"]
49                          onHost:[ud stringForKey:@"LDAPHost"]
50                          port:0];
51   if (ok)
52     printf("authenticated successfully.\n");
53   else
54     printf("did not authenticate !\n");
55   
56   [pool release];
57   
58   exit(0);
59   return 0;
60 }