Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

100 lines
1.9 KiB

  1. /*++
  2. SETPROP.C
  3. umappl to set properties.
  4. Copyright (C) 1998 Microsoft Corporation, all rights reserved.
  5. Created, Jun 18, 1998 by DavidCHR.
  6. --*/
  7. #include "master.h"
  8. #include "keytab.h"
  9. #include <winldap.h>
  10. #include <malloc.h>
  11. #include "secprinc.h"
  12. #include "options.h"
  13. int __cdecl
  14. main( int argc,
  15. PCHAR argv[] ) {
  16. LPSTR TargetDn = NULL;
  17. LPSTR PropertyName = NULL;
  18. LPSTR PropertyValue = NULL;
  19. ULONG Operation = LDAP_MOD_ADD;
  20. optEnumStruct Operations[] = {
  21. { "Add", (PVOID) LDAP_MOD_ADD, "Add the value (default)" },
  22. { "Replace", (PVOID) LDAP_MOD_REPLACE, "change the value" },
  23. { "Delete", (PVOID) LDAP_MOD_DELETE, "Delete the value" },
  24. TERMINATE_ARRAY
  25. };
  26. optionStruct options[] = {
  27. { "?", NULL, OPT_HELP },
  28. { "TargetDn", &TargetDn, OPT_STRING | OPT_NONNULL | OPT_DEFAULT,
  29. "target to set property of." },
  30. { "PropertyName", &PropertyName,
  31. OPT_STRING | OPT_NONNULL | OPT_DEFAULT,
  32. "Name of the property we're setting." },
  33. { "PropertyVal", &PropertyValue,
  34. OPT_STRING | OPT_NONNULL | OPT_DEFAULT,
  35. "Value we'll set the property to." },
  36. { "op", &Operation, OPT_ENUMERATED | OPT_ENUM_IS_MASK,
  37. "What to do to the object property",
  38. Operations },
  39. TERMINATE_ARRAY
  40. };
  41. PVOID pvTrash;
  42. PLDAP pLdap;
  43. LPSTR BaseDn;
  44. int ret;
  45. ParseOptionsEx( argc-1,
  46. argv+1,
  47. options,
  48. OPT_FLAG_TERMINATE,
  49. &pvTrash,
  50. NULL, NULL );
  51. if ( ConnectToDsa( &pLdap,
  52. &BaseDn ) ) {
  53. free( BaseDn );
  54. if ( SetStringProperty( pLdap,
  55. TargetDn,
  56. PropertyName,
  57. PropertyValue,
  58. Operation ) ) {
  59. ret = 0;
  60. fprintf( stderr,
  61. "success!\n" );
  62. } else ret = GetLastError();
  63. ldap_unbind( pLdap );
  64. } else ret = 3;
  65. return ret;
  66. }