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: Mike Lasky <mlasky@novell.com>
22
|***************************************************************************/
31
namespace Simias.Storage
34
/// Class that represents a Domain object in the Collection Store.
36
public class Domain : Collection
40
/// Defines the different types of synchronization configurations.
42
public enum ConfigurationType
45
/// Doesn't sychronize.
50
/// Workgroup (e.g. Rendevous, Gaim, etc)
55
/// Client/Server (e.g. Enterprise, SimpleServer, etc)
61
/// Configuration section name where enterprise key value pairs are stored.
63
static public string SectionName = "Domain";
64
static public string AdminDNTag = "AdminDN";
65
static public string Encoding = "Encoding";
68
/// Current version of the domain.
70
public static readonly Version CurrentDomainVersion = new Version( "1.0.0.0" );
76
/// Gets the domain configuration type.
78
public ConfigurationType ConfigType
82
Property p = properties.FindSingleValue( PropertyTags.DomainType );
83
return ( p != null ) ? ( ConfigurationType )p.Value : ConfigurationType.None;
88
/// Gets or sets the domain description.
90
public string Description
94
Property p = properties.GetSingleProperty( PropertyTags.Description );
95
return ( p != null ) ? p.Value as String : null;
98
set { properties.ModifyNodeProperty( PropertyTags.Description, value ); }
101
#if ( !REMOVE_OLD_INVITATION )
103
/// Used to determine if the domain supports the new invitation model.
105
public bool SupportsNewInvitation
107
get { return ( DomainVersion >= CurrentDomainVersion ) ? true : false; }
111
/// Gets or sets the version of this domain.
113
public Version DomainVersion
117
Property p = properties.GetSingleProperty( PropertyTags.DomainVersion );
118
return ( p != null ) ? new Version( p.Value as String ) : new Version( "0.0.0.0" );
121
set { properties.ModifyNodeProperty( PropertyTags.DomainVersion, value.ToString() ); }
126
/// <param name="store">Store object.</param>
127
/// <param name="domainName">Name of the domain.</param>
128
/// <param name="domainID">Well known unique identifier for the domain.</param>
129
/// <param name="description">String that describes this domain.</param>
130
/// <param name="role">The type of synchronization role this domain has.</param>
131
/// <param name="configType">The synchronization configuration type for this domain.</param>
132
public Domain( Store store, string domainName, string domainID, string description, SyncRoles role, ConfigurationType configType ) :
133
base ( store, domainName, domainID, NodeTypes.DomainType, domainID )
135
// Add the description attribute.
136
if ( ( description != null ) && ( description.Length > 0 ) )
138
properties.AddNodeProperty( PropertyTags.Description, description );
141
// Set the current domain version.
142
DomainVersion = CurrentDomainVersion;
144
// Add the sync role for this collection.
147
// Add the configuration type.
148
Property p = new Property( PropertyTags.DomainType, configType );
149
p.LocalProperty = true;
150
properties.AddNodeProperty( p );
152
// When sync the policy node (always sync is initiated from slave) is syned from master to slave
153
// the master is overwritten to slave, the slave changes will be lost
154
// when there is no change in master, the slave changes will be synced to master
155
// This is to ensure that the master policy over rides the slave policy.
156
// Ideally we should have a master policy which is read only in slave and
157
// slave specific policy which should not be synced to master.
158
CollisionPolicy = CollisionPolicy.ServerWins;
162
/// Constructor to create an existing Domain object from a Node object.
164
/// <param name="storeObject">Store object that this collection belongs to.</param>
165
/// <param name="node">Node object to construct this object from.</param>
166
public Domain( Store storeObject, Node node ) :
167
base( storeObject, node )
172
/// Constructor for creating an existing Domain object from a ShallowNode.
174
/// <param name="storeObject">Store object that this collection belongs to.</param>
175
/// <param name="shallowNode">A ShallowNode object.</param>
176
public Domain( Store storeObject, ShallowNode shallowNode ) :
177
base( storeObject, shallowNode )
182
/// Constructor to create an existing Domain object from an Xml document object.
184
/// <param name="storeObject">Store object that this collection belongs to.</param>
185
/// <param name="document">Xml document object to construct this object from.</param>
186
internal Domain( Store storeObject, XmlDocument document ) :
187
base( storeObject, document )
192
#region Public Methods
194
/// Returns if the specified user's login is disabled.
196
/// <param name="userID">User ID for the member to check.</param>
197
/// <returns>True if the login for the specified user is disabled.</returns>
198
public bool IsLoginDisabled( string userID )
200
Member member = GetMemberByID( userID );
201
if ( member == null )
203
throw new DoesNotExistException( "The specified user does not exist." );
206
Property p = member.Properties.GetSingleProperty( PropertyTags.LoginDisabled );
207
return ( p != null ) ? ( bool )p.Value : false;
211
/// Sets the specified user's login disabled status.
213
/// <param name="userID">User ID for the member to set the status for.</param>
214
/// <param name="disable">True to disable login or False to enable login.</param>
215
public void SetLoginDisabled( string userID, bool disable )
217
Member member = GetMemberByID( userID );
218
if ( member == null )
220
throw new DoesNotExistException( "The specified user does not exist." );
225
Property p = new Property( PropertyTags.LoginDisabled, true );
226
p.LocalProperty = true;
227
member.Properties.ModifyNodeProperty( p );
232
Property p = member.Properties.GetSingleProperty( PropertyTags.LoginDisabled );
242
/// Obtains the string representation of this instance.
244
/// <returns>The friendly name of the domain.</returns>
245
public override string ToString()