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
|***************************************************************************/
25
using System.Security.Cryptography;
27
using System.Web.Services;
28
using System.Web.Services.Protocols;
33
namespace Simias.Server
36
/// The registration status.
38
public enum RegistrationStatus
41
/// The user was created.
46
/// The user already exists.
51
/// Invalid parameters were specified.
56
/// Invalid domain was specified.
61
/// Username policy exception.
63
UsernamePolicyException,
66
/// Password policy exception.
68
PasswordPolicyException,
71
/// No user providers are registered.
73
NoRegisteredUserProvider,
76
/// The method is not supported.
81
/// An internal exception occurred.
87
/// Class that represents the current state and configuration
88
/// of the synchronization service.
91
public class RegistrationInfo
94
/// Constructs a RegistrationInfo object.
96
public RegistrationInfo()
101
/// Constructs a RegistrationInfo object.
103
/// <param name="StatusCode">The status of the registration.</param>
104
public RegistrationInfo( RegistrationStatus StatusCode )
110
/// Status result from a create or delete
113
public RegistrationStatus Status;
116
/// Message returned from the CreateUser method.
118
public string Message;
121
/// Guid assigned to the user.
122
/// Not valid if the registration method fails.
124
public string UserGuid;
127
/// Distinguished Name in the external identity database.
128
/// Not valid if the registration method fails.
130
public string DistinguishedName;
133
/// If the Registration.CreateUser method fails with a
134
/// UserExists status, the provider MAY return a list of
135
/// suggested names the caller could try.
137
public string[] SuggestedNames;
142
/// Web service methods to manage the Identity Sync Service
145
Namespace="http://novell.com/simias-server/registration",
146
Name="User Registration",
147
Description="Web Service providing self provisioning/registration for Simias users.")]
148
public class Registration : System.Web.Services.WebService
150
private Store store = null;
153
/// Used to log messages.
155
private static readonly ISimiasLog log =
156
SimiasLogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
161
public Registration()
163
store = Store.GetStore();
167
/// Method to get the domain's public key
169
[WebMethod( EnableSession = true )]
175
Simias.Storage.Domain domain = store.GetDomain( store.LocalDomain );
176
RSACryptoServiceProvider pubKey = domain.Owner.PublicKey;
178
log.Debug( "Public Key: " + pubKey.ToString() );
179
log.Debug( "Public Key (XML): " + pubKey.ToXmlString( false ) );
181
return pubKey.ToXmlString( false );
185
/// Method to add/create a new user in the system.
187
/// <param name="Username">Username (mandatory) short name of the user</param>
188
/// <param name="Password">Password (mandatory)</param>
189
/// <param name="UserGuid">UserGuid (optional) caller can specify the guid for the user</param>
190
/// <param name="FirstName">FirstName (optional) first/given name of the user</param>
191
/// <param name="LastName">LastName (optional) last/family name of the user</param>
192
/// <param name="FullName">FullName (optional) Fullname of the user</param>
193
/// <param name="DistinguishedName">DistinguishedName (optional) usually the distinguished name from an external identity store</param>
194
/// <param name="Email">Email (optional) Primary email address</param>
196
/// If the FirstName and LastName are specified but the FullName is null, FullName is
197
/// autocreated using: FirstName + " " + LastName
199
[WebMethod( EnableSession = true )]
210
string DistinguishedName,
213
RegistrationInfo info;
215
if ( Username == null || Username == "" || Password == null )
217
info = new RegistrationInfo( RegistrationStatus.InvalidParameters );
218
info.Message = "Missing mandatory parameters";
219
log.Info( "called with missing mandatory parameters" );
223
Simias.Server.User user = new Simias.Server.User( Username );
224
user.FirstName = FirstName;
225
user.LastName = LastName;
226
user.UserGuid = UserGuid;
227
user.FullName = FullName;
228
user.DN = DistinguishedName;
231
info = user.Create( Password );