/// <summary> /// Gets the host address property from the domain object. /// </summary> /// <param name="collectionID">Identifier for the domain.</param> /// <returns>A Uri object containing the host address for the /// domain if successful. Otherwise returns a null.</returns> private Uri GetHostAddressForCollection(string collectionID) { Uri hostAddress = null; Collection collection = store.GetCollectionByID(collectionID); if (collection != null) { // Get the address from the host. HostNode host = collection.Host; if (host != null) { hostAddress = new Uri(host.PublicUrl); } else { Domain domain = store.GetDomain(collection.Domain); Property p = domain.Properties.FindSingleValue(PropertyTags.HostAddress); if (p != null) { hostAddress = p.Value as Uri; } } } return(hostAddress); }
/// <summary> /// Method to provision a member into the Simias system. /// The actual provisioning is handled by the registered /// provider. /// </summary> public static Simias.Host.HostInfo ProvisionUser(string Username) { if (callout != null) { string HostId = null; Simias.Host.HostInfo hinfo = null; logger.Debug("Provsioning user {0}", Username); if (Simias.Service.Manager.LdapServiceEnabled == false) { HostId = callout(Username); } else { HostId = callout(Username); if (HostId == null) { logger.Debug("AttributeProvisionUserProvider Failed to provision: {0} {1}", Username, "Calling LoadBalanceProvisionUserProvider for provisioning"); LoadBalanceProvisionUserProvider userProvider = new LoadBalanceProvisionUserProvider(); HostId = userProvider.ProvisionUser(Username); } } Store store = Store.GetStore(); Domain domain = store.GetDomain(store.DefaultDomain); HostNode hNode = HostNode.GetHostByID(domain.ID, HostId); hinfo = new Simias.Host.HostInfo(hNode); return(hinfo); } else { logger.Debug("Provisioning user {0} using the default algorithm", Username); return(defaultProvisionUser(Username)); } }
public HostInformation GetHostInfo(string CollectionID, string HostID) { HostInformation hostinfo = null; if (CollectionID == null || CollectionID == String.Empty) { HostNode hn = HostNode.GetHostByID(hostDomain.ID, HostID); hostinfo = new HostInformation(hn); } else { Collection collection = store.GetCollectionByID(CollectionID); if (collection != null) { Member member = collection.GetMemberByID(HostID); if (member != null) { HostNode hn = HostNode.GetHostByID(hostDomain.ID, HostID); hostinfo = new HostInformation(hn); hostinfo.ID = member.ID; } } } return(hostinfo); }
/// <summary> /// Gets the host address property from the domain object. /// </summary> /// <param name="domainID">Identifier for the domain.</param> /// <returns>A Uri object containing the host address for the /// domain if successful. Otherwise returns a null.</returns> private Uri GetDomainHostAddress(string domainID) { Uri hostAddress = null; Domain domain = store.GetDomain(domainID); if (domain != null) { // Get the address from the host. HostNode host = domain.Host; if (host != null) { hostAddress = new Uri(host.PublicUrl); } else { Property p = domain.Properties.FindSingleValue(PropertyTags.HostAddress); if (p != null) { hostAddress = p.Value as Uri; } } } return(hostAddress); }
/// <summary> /// constructor /// </summary> /// <param name="hNode">HostNode object</param> internal HostEntry(HostNode hNode) { host = hNode; ICSList members = hNode.GetHostedMembers(); userCount = members.Count; }
public void DeleteHost(string id) { Domain domain = this.domain; HostNode host = (HostNode)domain.GetNodeByID(id); domain.Commit(domain.Delete(host)); }
/// <summary> /// Returns the network location for the the specified /// collection. /// </summary> /// <param name="domainID">Identifier for the domain that the /// collection belongs to.</param> /// <param name="collectionID">Identifier of the collection to /// find the network location for.</param> /// <returns>A Uri object that contains the network location. /// </returns> public Uri ResolveLocation(string domainID, string collectionID) { // This is only called by a server return the private address. Uri hostAddress = null; Domain domain = store.GetDomain(domainID); if (domain != null) { // Get the address from the host. HostNode host = domain.Host; if (host != null) { hostAddress = new Uri(host.PublicUrl); } else { Property p = domain.Properties.GetSingleProperty(PropertyTags.HostAddress); if (p != null) { hostAddress = p.Value as Uri; } } } return(hostAddress); }
public Simias.Host.HostInfo[] GetHosts() { Simias.Server.EnterpriseDomain enterpriseDomain = new Simias.Server.EnterpriseDomain(false); if (enterpriseDomain == null) { throw new SimiasException("Enterprise server domain does not exist."); } Simias.Host.HostInfo[] infoList; HostNode[] hosts = HostNode.GetHosts(enterpriseDomain.ID); if (hosts.Length > 0) { infoList = new Simias.Host.HostInfo[hosts.Length]; int i = 0; foreach (HostNode hn in hosts) { infoList[i++] = new Simias.Host.HostInfo(hn); } } else { infoList = new Simias.Host.HostInfo[0]; } return(infoList); }
public string AddHost(string name, string publicAddress, string privateAddress, string publicKey, out bool created) { // Get the HostDomain // If the domain does not exist create it and and this host to it. // Add the host to the Host domain if it does not already exist. // Check if the host already exists. created = false; HostNode hNode = null; // This is not the right master host, so fail the registration process if ((hNode = HostNode.GetLocalHost()) == null || !hNode.IsMasterHost) { return(null); } Member host = hostDomain.GetMemberByName(name); if (host == null) { RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(); rsa.FromXmlString(publicKey); // Now add the new host. host = new HostNode(name, System.Guid.NewGuid().ToString(), publicAddress, privateAddress, rsa); domain.Commit(host); created = true; } return(host.Properties.ToString(true)); }
/// <summary> /// Method to read and load the host instance settings section. /// </summary> /// <param name="path">BizTalk group settings file path</param> /// <returns></returns> public static HostInstanceSettings LoadBizTalkHostInstancesSettings(string path) { HostInstanceSettings settings; try { XmlDocument document = new XmlDocument(); document.Load(path); List <ServerSettingsContainerWithNameAttr> settingsContainer = new List <ServerSettingsContainerWithNameAttr>(); foreach (XmlNode HostNode in document.SelectNodes("/Settings/HostInstanceSettings/Host")) { List <SettingsContainerWithNameAttr> container = new List <SettingsContainerWithNameAttr>(1); foreach (XmlNode serverNode in HostNode.SelectNodes("Server")) { var list = new List <SettingElement>(1); foreach (XmlNode settingsNode in serverNode.SelectNodes("Setting")) { list.Add(new SettingElement(settingsNode.Attributes["Name"].Value, settingsNode.InnerText)); } container.Add(new SettingsContainerWithNameAttr(serverNode.Attributes["Name"].Value, list)); } settingsContainer.Add(new ServerSettingsContainerWithNameAttr(HostNode.Attributes["Name"].Value, container)); } settings = new HostInstanceSettings(settingsContainer); } catch (Exception exception) { throw exception; } return(settings); }
/// <summary>If the list reflects an attrib, this reserialises it.</summary> public override void Reserialize() { if (HostNode == null) { return; } // Create builder: System.Text.StringBuilder sb = new System.Text.StringBuilder(); int count = Values.Count; for (int i = 0; i < count; i++) { // Separated by spaces: if (i != 0) { sb.Append(' '); } // Serialize it: Values[i].Serialize(sb); } // Output it: HostNode.setAttribute(AttributeName, sb.ToString()); }
public override int GetHashCode() { unchecked { return((Id.GetHashCode() * 397) ^ HostNode.GetHashCode()); } }
/// <summary> /// Delete the collection from catalog /// </summary> /// <param name="domainID">Domain ID in which collection is present</param> /// <param name="collectionID">Collection ID to delete</param> public static void DeleteCollectionInCatalog(string domainID, string collectionID) { log.Debug("Domain ID {0}, col ID {1}", domainID, collectionID); Member member = Store.GetStore().GetDomain(domainID).GetCurrentMember(); HostNode hNode = GetHostNode(domainID, collectionID); if (hNode == null) { hNode = member.HomeServer; } try { log.Debug("DeleteCollectionInCatalog called from client"); DiscoveryService dService = new DiscoveryService(); SimiasConnection smConn = new SimiasConnection(domainID, member.UserID, SimiasConnection.AuthType.BASIC, hNode); smConn.InitializeWebClient(dService, "DiscoveryService.asmx"); dService.DeleteCollectionInCatalog(collectionID); } catch (Exception ex) { log.Error(ex.Message); } return; }
/// <summary> /// Remove the membership of collection from domain /// </summary> /// <param name="domainID">Domain ID where collection resides</param> /// <param name="collectionID">Collection ID to remove from domain</param> /// <returns></returns> public static bool RemoveMembership(string domainID, string collectionID) { bool removed = false; Domain domain = Store.GetStore().GetDomain(domainID); Member member = domain.GetCurrentMember(); HostNode hNode = GetHostNode(domainID, collectionID); if (hNode == null) { hNode = member.HomeServer; } try { DiscoveryService dService = new DiscoveryService(); SimiasConnection smConn = new SimiasConnection(domainID, member.UserID, SimiasConnection.AuthType.BASIC, hNode); smConn.InitializeWebClient(dService, "DiscoveryService.asmx"); removed = dService.RemoveMemberFromCollection(collectionID, member.UserID); } catch (Exception ex) { log.Error(ex.Message); } return(removed); }
/// <summary> /// Get the host node depending on domain ID and collectionID /// </summary> /// <param name="domainID">ID of the domain</param> /// <param name="collectionID">Collection ID</param> /// <returns>Object of HostNode</returns> private static HostNode GetHostNode(string domainID, string collectionID) { try { HostNode hNode = null; CollectionInfo ci = GetCollectionInfo(collectionID); if (ci != null) { string hostID = ci.HostID; if (hostID != null) { Domain domain = Store.GetStore().GetDomain(domainID); Member hMember = domain.GetMemberByID(hostID); if (hMember != null) { log.Debug("Initializing hNode"); hNode = new HostNode(hMember); } } } return(hNode); } catch (Exception ex) { log.Error(ex.Message); return(null); } }
public string GetDomain() { // We need to add the hostID to this node. Domain d = domain; d.Host = HostNode.GetLocalHost(); return(d.Properties.ToString(false)); }
public void DeleteHost(string id) { Domain domain = this.domain; HostNode host = domain.GetNodeByID(id) as HostNode; Catalog.DeleteSlaveEntryFromCatalog(host.Name); domain.Commit(domain.Delete(host)); }
/// <summary> /// constructor /// </summary> /// <param name="node">HostNode object</param> internal HostInfo(HostNode node) { ID = node.UserID; PublicAddress = node.PublicUrl; PrivateAddress = node.PrivateUrl; PublicKey = node.PublicKey.ToXmlString(false); Master = node.IsMasterHost; }
public void DeleteHostByName(string Name) { Domain domain = this.domain; Catalog.DeleteSlaveEntryFromCatalog(Name); HostNode host = HostNode.GetHostByName(domain.ID, Name); domain.Commit(domain.Delete(host)); }
public CollectionInfo(string CollectionID, string UserID) { Collection c = Store.GetStore().GetCollectionByID(CollectionID); CatalogEntry entry = Catalog.GetEntryByCollectionID(CollectionID); // this.ID = entry.ID; this.ID = c.ID; this.CollectionID = c.ID; this.Name = c.Name; this.Description = GetStringProperty(c, PropertyTags.Description); this.DomainID = c.Domain; // this.HostID = c.HostID; this.HostID = HostNode.GetLocalHost().UserID; this.DirNodeID = c.GetRootDirectory().ID; this.DirNodeName = c.GetRootDirectory().Name; this.Size = c.StorageSize; this.Created = GetDateTimeProperty(c, PropertyTags.NodeCreationTime); this.LastModified = GetDateTimeProperty(c, PropertyTags.JournalModified); this.MemberCount = c.GetMemberList().Count; this.Disabled = c.Disabled; this.OwnerID = c.Owner.UserID; Domain domain = Store.GetStore().GetDomain(this.DomainID); Member domainMember = domain.GetMemberByID(this.OwnerID); this.OwnerUserName = domainMember.Name; string fullName = domainMember.FN; this.OwnerFullName = (fullName != null) ? fullName : this.OwnerUserName; this.encryptionAlgorithm = c.EncryptionAlgorithm; this.MigratediFolder = c.MigratediFolder; Member member = c.GetMemberByID(UserID); if (member == null && Simias.Service.Manager.LdapServiceEnabled == true) { string[] IDs = domain.GetMemberFamilyList(UserID); foreach (string id in IDs) { member = c.GetMemberByID(id); if (member != null) { break; } } } if (member != null) { this.MemberNodeID = member.ID; this.MemberUserID = member.UserID; this.UserRights = member.Rights.ToString(); } }
/// <summary> /// get host from tempHostFileName /// </summary> /// <param name="storePath">path</param> /// <returns>HostNode object</returns> internal static HostNode GetHost(string storePath) { XmlDocument doc = new XmlDocument(); doc.LoadXml(GetXmlDoc(storePath, tempHostFileName)); HostNode hnode = new HostNode(Node.NodeFactory(Store.GetStore(), doc)); return(hnode); }
/// <summary> /// Returns the network address of the host /// </summary> /// <param name="domainID">Identifier of the domain where a /// collection is to be created.</param> /// <param name="hostID">The host to resolve.</param> /// <returns>A Uri object that contains the network location.</returns> public Uri ResolveHostAddress(string domainID, string hostID) { HostNode host = HostNode.GetHostByID(domainID, hostID); if (host != null) { return(new Uri(host.PrivateUrl)); } return(null); }
/// <summary> /// constructor /// </summary> /// <param name="node">HostNode object</param> internal HostInformation(HostNode node) { ID = node.ID; MemberID = node.UserID; Name = node.Name; PublicAddress = node.PublicUrl; PrivateAddress = node.PrivateUrl; PublicKey = node.PublicKey.ToXmlString(false); Master = node.IsMasterHost; }
public override void Reserialize() { if (HostNode == null || baseValue_ == null) { return; } // Just flush out the length: HostNode.setAttribute(AttributeName, baseValue_.valueAsString); }
/// <summary> /// Based on DN, check whther this user is provisioned or not /// </summary> /// <param name="Dn">User's DN</param> /// <returns>HostNode if user is provisioned otherwise null</returns> public HostNode checkUserProvisionedByDN(string Dn) { HostNode hostnode = null; Member member = domain.GetMemberByDN(Dn); if (member != null) { hostnode = member.HomeServer; } return(hostnode); }
private void es_NodeCreated(Simias.Client.Event.NodeEventArgs args) { Member member = domain.GetNodeByID(args.Node) as Member; if (member.IsType(HostNode.HostNodeType)) { HostNode hostnode = new HostNode(member); HostEntry hostentry = new HostEntry(hostnode); hosts.Add(hostentry); } }
/// <summary> /// Sets HomeServer for this DN, which is nearest /// </summary> /// <param name="Dn">DN of user</param> /// <returns>HomeServer if succesful, else null</returns> public HostNode SetUserHomeServer(string Dn) { HostNode hostnode = null; Member member = domain.GetMemberByDN(Dn); hostnode = checkUserProvisionedByDN(Dn); log.Debug(String.Format("SetUserHomeServer {0}", Dn)); if (hostnode == null) { if (Dn.ToLower().IndexOf("ou") >= 0) { foreach (HostEntry hentry in hosts) { //Org Unit to machine name mapping is to be done... string orgUnit = ""; string pubUrl = hentry.Host.PublicUrl; if (pubUrl.IndexOf(orgUnit) >= 0) { log.Debug(String.Format("Setting the home server for {0} to {1}", Dn, orgUnit)); hostnode = hentry.Host; hentry.AddMember(domain, member); return(hostnode); } } } else { //Check groups and then provision the user. string groupList = String.Empty; try { groupList = member.Properties.GetSingleProperty("UserGroups").Value as string; } catch {} if (groupList != String.Empty && groupList != "") { string[] groupArray = groupList.Split(new char[] { ';' }); foreach (string group in groupArray) { hostnode = SetUserHomeServer(group); if (hostnode != null) { log.Debug(String.Format("Setting the home server for {0} to {1}'s homeserver ", Dn, group)); HostEntry hentry = new HostEntry(hostnode); hentry.AddMember(domain, member); return(hostnode); } } } } } return(hostnode); }
public bool SetHomeServer(string userID, string serverID) { try { Member member = GetDomainMemberByID(userID); member.HomeServer = HostNode.GetHostByID(domain.ID, serverID); domain.Commit(member); return(true); } catch { } return(false); }
/// <summary> /// Check whether user is provisioned or not based on userID /// </summary> /// <param name="userID">userid to be checked</param> /// <returns>HostNode if provisioned, otherwise null</returns> public static HostNode checkUserProvisionedByID(string userID) { Store store = Store.GetStore(); Domain domain = store.GetDomain(store.DefaultDomain); HostNode hostnode = null; Member member = domain.GetMemberByID(userID); if (member != null) { hostnode = member.HomeServer; } return(hostnode); }
public HostInfo GetHomeServer(string userName) { Member member = GetDomainMemberByName(userName); HostNode host = member.HomeServer; if (host != null) { // We need to provision this user. // This is a single server system. return(new HostInfo(host)); } return(null); }