1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-12 09:18:10 +03:00
Commit Graph

94 Commits

Author SHA1 Message Date
Andrew Bartlett
34b2e558a4 Always escape ldap filter strings. Escaping code was from pam_ldap, but I'm to
blame for the realloc() stuff.

Plus a couple of minor updates to libads.

Andrew Bartlett
0001-01-01 00:00:00 +00:00
Gerald Carter
ec26877f0b sanity checks from Ken Cross 0001-01-01 00:00:00 +00:00
Andrew Bartlett
92a777d0ea BIG patch...
This patch makes Samba compile cleanly with -Wwrite-strings.
 - That is, all string literals are marked as 'const'.  These strings are
always read only, this just marks them as such for passing to other functions.

What is most supprising is that I didn't need to change more than a few lines of code (all
in 'net', which got a small cleanup of net.h and extern variables).  The rest
is just adding a lot of 'const'.

As far as I can tell, I have not added any new warnings - apart from making all
of tdbutil.c's function const (so they warn for adding that const string to
struct).

Andrew Bartlett
0001-01-01 00:00:00 +00:00
Jeremy Allison
e789edbb28 Catching up with old patches. Add define for VERITAS quota support.
Check return in ldap.
Jeremy.
0001-01-01 00:00:00 +00:00
Jeremy Allison
842e08e52a Forward port the change to talloc_init() to make all talloc contexts
named. Ensure we can query them.
Jeremy.
0001-01-01 00:00:00 +00:00
Jim McDonough
adda04379e More printer publishing code.
- Add published attribute to info2, needed for win clients to work properly
- Return proper info on getprinter 7

This means you can now look at the sharing tab of a printer and get correct
info about whether it is published or not, and change it.
0001-01-01 00:00:00 +00:00
Gerald Carter
c31a17889e [merge from APP_HEAD]
90% fix for CR 1076.  The password server parameter will no take things
like

        password server = DC1 *

which means to contact DC1 first and the go to auto lookup if it
fails.


jerry
0001-01-01 00:00:00 +00:00
Andrew Bartlett
f5d8afc626 Include the hostname we are trying to match with $@, to allow easier debugging. 0001-01-01 00:00:00 +00:00
Jeremy Allison
82b8f749a3 Removed global_myworkgroup, global_myname, global_myscope. Added liberal
dashes of const. This is a rather large check-in, some things may break.
It does compile though :-).
Jeremy.
0001-01-01 00:00:00 +00:00
Tim Potter
1e054e3db6 Merge of get_dc_list() api change. This was slightly more intrusive
than the version in APPLIANCE so watch out for boogs.
0001-01-01 00:00:00 +00:00
Jim McDonough
7eaf7e7115 Format objectGUIDs on ads dumps. 0001-01-01 00:00:00 +00:00
Andrew Tridgell
c0612272e8 only set UF_USE_DES_KEY_ONLY if we are using krb5 libraries that can't
do type 23
0001-01-01 00:00:00 +00:00
Andrew Tridgell
8ff6d40d7f .NET likes both forms of servicePrincipalName in the machine account
record
0001-01-01 00:00:00 +00:00
Andrew Bartlett
9615ab10c0 Try to compile as much as possible with only ldap, but not kerberos. 0001-01-01 00:00:00 +00:00
Andrew Bartlett
24fb0cde2f Add the beginings of sam_ads to the tree.
This module, primarilly the work of "Stefan (metze) Metzmacher"
<metze@metzemix.de>, uses the Active Directory schema to store the
user/group/other information.  I've been testing it against a real AD server,
and it is intended to work with OpenLDAP as well.

I've moved a few functions around in our other libads code, which has made it
easier to tap into that existing code.

Also, I've made some changes to the SAM interface, I hope there are not too
many objections...   To ensure we don't get silly bugs in the skel module, it
is now in the default compile.  This way you should not forget to update it :-)

Andrew Bartlett
0001-01-01 00:00:00 +00:00
Andrew Bartlett
c864edf4fb Move a number of ADS related functions out into utility libs, so that things
like metze's sam_ads can also use them.

Also add error checking etc to a few more functions.

Andrew Bartlett
0001-01-01 00:00:00 +00:00
Andrew Bartlett
ce00a3238e Some small cleanups to the libads code (mainly error checking), and give a
sane prototype for the push_utf8_allocate code.

Andrew Bartlett
0001-01-01 00:00:00 +00:00
Andrew Bartlett
9c62d1312f Another patch from metze, towards his work on sam_ads.
See mx-ldap.sf.net for his current progress.
0001-01-01 00:00:00 +00:00
Andrew Tridgell
0d28d76947 Add clock skew handling to our kerberos code. This allows us to cope with
the DC being out of sync with the local machine.
0001-01-01 00:00:00 +00:00
Andrew Bartlett
5b9a7ab901 Patch from "Stefan (metze) Metzmacher" <metze@metzemix.de>
to extend the ADS_STATUS system to include NTSTATUS, and to provide a better
general infrustructure for his sam_ads work.

I've also added some extra failure mode DEBUG()s to parts of the code.

NOTE:  The ADS_ERR_OK() macro is rather sensitive to braketing issues - without
the final set of brakets, the test is essentially inverted - causing some
intersting 'error = success' messages...

Andrew Bartlett
0001-01-01 00:00:00 +00:00
Andrew Bartlett
ad3c8da13b Add some DEBUG()s to some libads failure modes. 0001-01-01 00:00:00 +00:00
Andrew Tridgell
b04e91f660 convert the LDAP/SASL code to use GSS-SPNEGO if possible
we now do this:

- look for suported SASL mechanisms on the LDAP server
- choose GSS-SPNEGO if possible
- within GSS-SPNEGO choose KRB5 if we can do a kinit
- otherwise use NTLMSSP

This change also means that we no longer rely on having a gssapi
library to do ADS.

todo:
- add TLS/SSL support over LDAP
- change to using LDAP/SSL for password change in ADS
0001-01-01 00:00:00 +00:00
Herb Lewis
a5c59b2cd1 fix irix compile errors - cannot initialize array in declaration statement
with non-const values - strsep not defined
0001-01-01 00:00:00 +00:00
Andrew Tridgell
57916316ff when using netbios lookup methods make sure we try any BDCs even if
we get a response from WINS for a PDC, if the PDC isn't responding.
0001-01-01 00:00:00 +00:00
Andrew Tridgell
2ee0abb50f fixed a memory corruption bug in ads_try_dns() 0001-01-01 00:00:00 +00:00
Andrew Tridgell
e358d7b24c This fixes a number of ADS problems, particularly with netbiosless
setups.

- split up the ads structure into logical pieces. This makes it much
  easier to keep things like the authentication realm and the server
  realm separate (they can be different).

- allow ads callers to specify that no sasl bind should be performed
(used by "net ads info" for example)

- fix an error with handing ADS_ERROR_SYSTEM() when errno is 0

- completely rewrote the code for finding the LDAP server. Now try DNS
  methods first, and try all DNS servers returned from the SRV DNS
  query, sorted by closeness to our interfaces (using the same sort code
  as we use in replies from WINS servers). This allows us to cope with
  ADS DCs that are down, and ensures we don't pick one that is on the
  other side of the country unless absolutely necessary.

- recognise dnsRecords as binary when displaying them

- cope with the realm not being configured in smb.conf (work it out
  from the LDAP server)

- look at the trustDirection when looking up trusted domains and don't
  include trusts that trust our domains but we don't trust
  theirs.

- use LDAP to query the alternate (netbios) name for a realm, and make
  sure that both and long and short forms of the name are accepted by
  winbindd. Use the short form by default for listing users/groups.

- rescan the list of trusted domains every 5 minutes in case new trust
  relationships are added while winbindd is running

- include transient trust relationships (ie. C trusts B, B trusts A,
  so C trusts A) in winbindd.

- don't do a gratuituous node status lookup when finding an ADS DC (we
  don't need it and it could fail)

- remove unused sid_to_distinguished_name function

- make sure we find the allternate name of our primary domain when
  operating with a netbiosless ADS DC (using LDAP to do the lookup)

- fixed the rpc trusted domain enumeration to support up to approx
  2000 trusted domains (the old limit was 3)

- use the IP for the remote_machine (%m) macro when the client doesn't
  supply us with a name via a netbios session request (eg. port 445)

- if the client uses SPNEGO then use the machine name from the SPNEGO
  auth packet for remote_machine (%m) macro

- add new 'net ads workgroup' command to find the netbios workgroup
  name for a realm
0001-01-01 00:00:00 +00:00
Andrew Bartlett
eb3354aa6c Now that I got the function arguments sane, remove the silly (void **) casts
from some of the callers.

Andrew Bartlett
0001-01-01 00:00:00 +00:00
Andrew Bartlett
30d0998c8c More fixes towards warnings on the IRIX compiler
(and yes, some of these are real bugs)

In particular, the samr code was doing an &foo of various types, to a function
that assumed uint32.  If time_t isn't 32 bits long, that broke.

They are assignment compatible however, so use that and an intermediate
variable.

Andrew Bartlett
0001-01-01 00:00:00 +00:00
Andrew Tridgell
fe1e6233c6 fix setting machine passwords in the case where a user account of the
same name as the machine name exists. (we ended up setting the users
password, not the machines password!)
0001-01-01 00:00:00 +00:00
Andrew Tridgell
5538048e4f this implements a completely new strategy for fetching group
membership from an ADS server. We now use a 'member' query on the
group and do a separate call to convert the resulting distinguished
name to a name, rid etc. This is *much* faster for very large numbers
of groups (on a quantum test system with 10000 groups it drops the
time from an hour to about 35 seconds).

strangely enough, this actually *increases* the amount of ldap
traffic, its just that the MS LDAP server answers these queries much
faster.
0001-01-01 00:00:00 +00:00
Andrew Tridgell
a92834ea94 this fixes the ads dump code
a char** isn't quite the same thing as a struct berval**  :)
0001-01-01 00:00:00 +00:00
Andrew Tridgell
022073d140 make sure we disable referrals in all ldap searches - they are badly
broken
0001-01-01 00:00:00 +00:00
Andrew Tridgell
e7f588d815 ads_mod_ber should be static, not public
this fixes the huge number of struct berval warnings on non-ads
compiles
0001-01-01 00:00:00 +00:00
Jim McDonough
b81bc2b34b Const cleanup...should only be 2 warnings left from calling lib/util_str.c
str_list_copy().  Perhaps its proto should be fixed.
0001-01-01 00:00:00 +00:00
Jim McDonough
b361089360 Reduce compiler warnings. 0001-01-01 00:00:00 +00:00
Jim McDonough
f924cb5358 Support utf8 on the wire for ads ldap. DN's are converted, as well as strings,
though it is up to the calling function to decide whether values are
strings or not.  Attributes are not converted at this point, though support
for it would be simple.

I have tested it with users and groups using non-ascii chars, and if the
check for alphanumeric user/domain names is removed form sesssetup.c, even
a user with accented chars can connect, or even login (via winbind).

I have also simplified the interfaces to ads_mod_*, though we will probably
want to expand this by a few functions in the near future.  We just had
too many ways to do the same thing...
0001-01-01 00:00:00 +00:00
Andrew Bartlett
b84882a628 This is meant to be accessed via the helper fn, not directly. 0001-01-01 00:00:00 +00:00
Andrew Tridgell
8096032663 fixed trust relationships in ADS winbindd after breaking them with my BDC changes ... 0001-01-01 00:00:00 +00:00
Andrew Tridgell
3e58a1ee83 fixed the fallback to a BDC for ADS connections 0001-01-01 00:00:00 +00:00
Jim McDonough
7aa5fa6172 A few more updates:
- Add doxygen comments
- remove server sort control (ms implementation was not reliable)
- rename ads_do_search_all2() to ads_do_search_all_fn()
0001-01-01 00:00:00 +00:00
Jim McDonough
95bec4c8ba Several updates to get server side sorting going:
- Added sort control to ads_do_paged_search.  It allows a char * to be passed
  as the sort key.  If NULL, no sort is done.
- fixed a bug in the processing of controls (loop wasn't incremented properly)
- Added ads_do_search_all2, which funs a function that is passed in against
  each entry.  No ldapmessage structures are returned.  Allows results to
  be processed as the come in on each page.

I'd like ads_do_search_all2 to replace ads_do_search_all, but there's some
work to be done in winbindd_ads.c first.

Also, perhaps now we can do async ldap searches?  Allow us to process a
page while the server retrieves the next one?
0001-01-01 00:00:00 +00:00
Jim McDonough
0475126ffb Try harder next time to not duplicate function...take ads_err2string back
out since it's already in ads_errstr() in ads_status.c
0001-01-01 00:00:00 +00:00
Jim McDonough
c937e13522 Add ads_err2string() function for generating error strings from an ADS_STATUS.
I've got the cases besides gssapi...anyone know how to get those?
0001-01-01 00:00:00 +00:00
Jim McDonough
f01f02fc56 Added ads_process_results(), which takes a function that is called for each
entry returned from a search, and applies it to the results.  Re-structured
ads_dump to use this, plus changed the ber_free in ads_dump from (b,1) to
(b,0), in accordance with openldap manpages.  Also allows proper free of
result using ldap_msgfree afterwards, so you can do something with the
results after an ads_dump.
0001-01-01 00:00:00 +00:00
Jim McDonough
71806c49b3 Whoops, left the paged control not critical in the paged search...kind of
defeats the purpose.
0001-01-01 00:00:00 +00:00
Jim McDonough
2bebc8a391 Add server control to prevent referrals in paged searches. This keeps
the scope limited to the domain at hand, and also keeps the openldap
libs happy, since they don't currently chase referrals and return
server controls properly at the same time.
0001-01-01 00:00:00 +00:00
Andrew Tridgell
514c11b4e3 added a ads_do_search_all() call, which is a more convenient interface
to paged searches. This makes updating winbindd to used paged searches
trivial.
0001-01-01 00:00:00 +00:00
Andrew Tridgell
8bf487ddff fixed paged controls on my box. The problem seems to be incorrect
referrals parsing in the openldap libs. By disabling referrals we get
valid controls back and the cookies work.
0001-01-01 00:00:00 +00:00
Jim McDonough
9afba67f9a This adds the Paged Result Control to ads searching. The new function, ads_do_paged_search, is the same as ads_do_search, but it also contains a count of records returned in this page, and a cookie for resuming, to be passed back. The cookie must start off NULL, and when it returns as NULL, the search is done. 0001-01-01 00:00:00 +00:00
Andrew Tridgell
9338964720 detect SIZELIMIT_EXCEEDED in ldap queries and truncate
the problem is, how the heck do we properly handle these? Jerry?

It seems that the Win2000 ADS server only returns a max of 1000 records!
0001-01-01 00:00:00 +00:00