4 * Microsoft Internet Location Server Protocol interface class.
6 * Portable Windows Library
8 * Copyright (c) 1993-2003 Equivalence Pty. Ltd.
10 * The contents of this file are subject to the Mozilla Public License
11 * Version 1.0 (the "License"); you may not use this file except in
12 * compliance with the License. You may obtain a copy of the License at
13 * http://www.mozilla.org/MPL/
15 * Software distributed under the License is distributed on an "AS IS"
16 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17 * the License for the specific language governing rights and limitations
20 * The Original Code is Portable Windows Library.
22 * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
24 * Contributor(s): ______________________________________.
27 * Revision 1.5 2003/06/05 23:19:52 rjongbloed
28 * Changed LDAP version to be compatible with ILS servers.
30 * Revision 1.4 2003/04/11 00:07:56 robertj
31 * More for Microsoft IP address specification wierdness (registration side).
33 * Revision 1.3 2003/04/07 13:05:20 robertj
34 * Workaround for Microsoft IP address specification wierdness.
36 * Revision 1.2 2003/03/31 12:18:43 robertj
37 * Fixed pragma implementation
39 * Revision 1.1 2003/03/31 03:35:20 robertj
40 * Major addition of LDAP functionality.
41 * Added ILS specialisation of LDAP.
46 #pragma implementation "pils.h"
51 #include <ptclib/pils.h>
56 // Microsoft in their infinite wisdom save the IP address as an little endian
57 // integer from a 32 bit integer that was in network byte order (big endian)
58 // which causes immense confusion. Reading into a PIPSocket::Address does not
59 // work as it assumes that any integer forms would be in host order.
60 istream
& operator>>(istream
& s
, PILSSession::MSIPAddress
& a
)
65 #if PBYTE_ORDER==PLITTLE_ENDIAN
68 a
= PIPSocket::Address((BYTE
)(u
>>24),(BYTE
)(u
>>16),(BYTE
)(u
>>8),(BYTE
)u
);
75 ostream
& operator<<(ostream
& s
, PILSSession::MSIPAddress
& a
)
77 #if PBYTE_ORDER==PLITTLE_ENDIAN
80 DWORD u
= (a
.Byte1()<<24)|(a
.Byte2()<<16)|(a
.Byte3()<<8)|a
.Byte4();
87 ///////////////////////////////////////////////////////////////////////////////
89 PILSSession::PILSSession()
90 : PLDAPSession("objectClass=RTPerson")
96 BOOL
PILSSession::AddPerson(const RTPerson
& person
)
98 return Add(person
.GetDN(), person
);
102 BOOL
PILSSession::ModifyPerson(const RTPerson
& person
)
104 return Modify(person
.GetDN(), person
);
108 BOOL
PILSSession::DeletePerson(const RTPerson
& person
)
110 return Delete(person
.GetDN());
114 BOOL
PILSSession::SearchPerson(const PString
& canonicalName
, RTPerson
& person
)
116 SearchContext context
;
117 if (!Search(context
, "cn="+canonicalName
))
120 if (!GetSearchResult(context
, person
))
123 // Return FALSE if there is more than one match
124 return !GetNextSearchResult(context
);
128 PList
<PILSSession::RTPerson
> PILSSession::SearchPeople(const PString
& filter
)
130 PList
<RTPerson
> persons
;
132 SearchContext context
;
133 if (Search(context
, filter
)) {
135 RTPerson
* person
= new RTPerson
;
136 if (GetSearchResult(context
, *person
))
137 persons
.Append(person
);
140 } while (GetNextSearchResult(context
));
147 PString
PILSSession::RTPerson::GetDN() const
152 dn
<< "c=" << c
<< ", ";
155 dn
<< "o=" << o
<< ", ";
157 dn
<< "cn=" + cn
+ ", objectClass=" + objectClass
;
166 // End of file ////////////////////////////////////////////////////////////////