1
/****************************************************************************
3
| Copyright (c) 2007 Novell, Inc.
6
| This program is free software; you can redistribute it and/or
7
| modify it under the terms of version 2 of the GNU General Public License as
8
| published by the Free Software Foundation.
10
| This program is distributed in the hope that it will be useful,
11
| but WITHOUT ANY WARRANTY; without even the implied warranty of
12
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
| GNU General Public License for more details.
15
| You should have received a copy of the GNU General Public License
16
| along with this program; if not, contact Novell, Inc.
18
| To contact Novell about this file by physical or electronic mail,
19
| you may find current contact information at www.novell.com
21
| Author: Brady Anderson <banderso@novell.com>
22
|***************************************************************************/
26
using System.Web.Services;
27
using System.Web.Services.Protocols;
29
namespace Simias.IdentitySync
32
/// Class that represents the state of the last
33
/// synchronization cycle
36
public class LastSyncInfo
39
/// Date and Time when the last sync cycle started
42
public string StartTime;
45
/// Date and Time when the last sync cycle finished
48
public string EndTime;
51
/// The number of members processed during the cycle
53
public int MembersProcessed;
56
/// Number of members added to the domain during
59
public int MembersAdded;
62
/// Number of members changed or updated because
63
/// of meta-data changing ex. First Name
65
public int MembersUpdated;
68
/// Number of members deleted from the domain during
71
public int MembersDeleted;
74
/// Number of members disabled in the domain during
77
public int MembersDisabled;
80
/// Number of reported errors during the cycle
82
public int ReportedErrors;
85
/// Messages reported during the cycle
87
public string[] Messages;
91
/// Class that represents the current state and configuration
92
/// of the synchronization service.
95
public class ServiceInfo
98
/// Date and Time when the synchronization engine was
102
public string UpSince;
105
/// Number of cycles the engine performed
110
/// Name of the registered synchronization provider
112
public string Provider;
115
/// Configured time interval, represented in seconds,
116
/// between synchronization cycles.
118
public int SynchronizationInterval;
121
/// Configured grace period, represented in seconds,
122
/// the sync service will allow a member to remain
123
/// in the domain when the member no longer exists
124
/// in the external identity store.
126
/// Members become disabled in the Simias domain when
127
/// they are no longer exist in the external store.
129
public int DeleteMemberGracePeriod;
132
/// Current status of the synchronization engine
133
/// status will be one of the following:
139
public string Status;
143
/// Identity Sync Manager
144
/// Web service methods to manage the Identity Sync Service
147
Namespace="http://novell.com/simias/idsyncmgr",
148
Name="Identity Sync Manager",
149
Description="Web Service providing management for the Identity Sync Service.")]
150
public class Manager : System.Web.Services.WebService
153
/// Used to log messages.
155
private static readonly ISimiasLog log =
156
SimiasLogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
165
private static string[] MonthsOfYear =
182
/// Method to disable the synchronization service
184
/// false - enables the synchronization service
185
/// Note! once enabled the service will enter a
186
/// synchronization cycle ignoring the configured
187
/// sync interval time.
190
[WebMethod( EnableSession = true )]
192
public void DisableSyncService( bool Disable )
194
IdentitySync.Service.syncDisabled = Disable;
198
/// Tells the sync service to immediately start
199
/// a synchronization cycle.
202
[WebMethod( EnableSession = true )]
204
public void SyncNow()
206
IdentitySync.Service.SyncNow( "" );
210
/// Get the current status of the identity sync service thread
215
/// Authentication Failure
219
[WebMethod( EnableSession = true )]
221
public ServiceInfo GetSyncServiceInfo()
223
ServiceInfo info = new ServiceInfo();
227
"{0}, {1} {2} {3} {4}:{5}:{6} GMT",
228
Service.upSince.DayOfWeek.ToString(),
230
Simias.IdentitySync.Manager.MonthsOfYear[ Service.upSince.Month - 1 ],
231
Service.upSince.Year.ToString(),
232
Service.upSince.Hour,
233
Service.upSince.Minute,
234
Service.upSince.Second );
236
info.Cycles = IdentitySync.Service.cycles;
238
// Get the first provider. At the moment, sync engine only supports
239
// one provider anyway.
240
foreach( IIdentitySyncProvider prov in Service.registeredProviders.Values )
242
info.Provider = prov.Name;
246
info.DeleteMemberGracePeriod = IdentitySync.Service.deleteGracePeriod;
247
info.SynchronizationInterval = IdentitySync.Service.syncInterval;
248
info.Status = IdentitySync.Service.status;
254
/// Get detailed information about the last synchronization
257
[WebMethod( EnableSession = true )]
259
public LastSyncInfo GetLastSyncInfo()
261
log.Debug( "GetLastSyncInfo - called" );
263
IdentitySync.State state = Simias.IdentitySync.Service.lastState;
269
LastSyncInfo info = new LastSyncInfo();
270
info.ReportedErrors = state.Errors;
271
info.MembersProcessed = state.Processed;
272
log.Debug( " members processed: " + info.MembersProcessed.ToString() );
276
"{0}, {1} {2} {3} {4}:{5}:{6} GMT",
277
state.StartTime.DayOfWeek.ToString(),
279
Simias.IdentitySync.Manager.MonthsOfYear[ state.StartTime.Month - 1 ],
280
state.StartTime.Year.ToString(),
281
state.StartTime.Hour,
282
state.StartTime.Minute,
283
state.StartTime.Second );
284
log.Debug( " sync start time: " + info.StartTime );
288
"{0}, {1} {2} {3} {4}:{5}:{6} GMT",
289
state.EndTime.DayOfWeek.ToString(),
291
Simias.IdentitySync.Manager.MonthsOfYear[ state.EndTime.Month - 1 ],
292
state.EndTime.Year.ToString(),
294
state.EndTime.Minute,
295
state.EndTime.Second );
296
log.Debug( " sync end time: " + info.EndTime );
298
info.MembersAdded = state.Created;
299
info.MembersUpdated = state.Updated;
300
info.MembersDeleted = state.Deleted;
301
info.MembersDisabled = state.Disabled;
303
log.Debug( " start processing messages" );
305
if ( state.Messages != null )
307
string[] messages = state.Messages;
308
info.Messages = new string[ messages.Length ];
309
for( int i = 0; i < messages.Length; i++ )
311
info.Messages[i] = messages[i];
321
/// Method to set the grace period a member is given
322
/// before they are removed from the domain.
323
/// Members are disabled during this grace period.
324
/// Represented in seconds
326
[WebMethod( EnableSession = true )]
328
public void SetDeleteMemberGracePeriod( int Seconds )
330
Service.deleteGracePeriod = Seconds;
334
/// Method to set the synchronization interval for the
335
/// sync engine. Represented in seconds
337
[WebMethod( EnableSession = true )]
339
public void SetSynchronizationInterval( int Seconds )
341
Service.syncInterval = Seconds;