コード例 #1
0
        public void TestZFDAppAssociation_ChangesFound()
        {
            LDAPZFDApp newApp = new LDAPZFDApp("cn=app1, ou=apps, o=kc");
            LDAPZFDApp existApp = new LDAPZFDApp("cn=app1, ou=apps, o=kc");
            List<string> newAssoc = new List<string>();
            List<string> oldAssoc = new List<string>();

            Console.WriteLine ("array1 count before {0}", newAssoc.Count);

            newAssoc.Add("cn=user1,ou=users,o=kc");
            oldAssoc.Add("cn=user2,ou=users,o=kc");

            newApp.setZENAppAssociations(newAssoc);
            existApp.setZENAppAssociations(oldAssoc);
            Console.WriteLine ("array1 count {0}", newAssoc.Count);
            Console.WriteLine ("array2 count {0}", oldAssoc.Count);
            ArrayList modlist = ZFDAppUtils.BuildZFDAppModifications(newApp, existApp);

            foreach (LdapModification s in modlist) {
                Console.WriteLine ("Changes {0}", s.Attribute);
                Assert.AreEqual("cn=user1,ou=users,o=kc", s.Attribute.StringValue);
                Assert.AreEqual("appAssociations", s.Attribute.Name);
            }

            Assert.AreEqual(1,modlist.Count);
        }
コード例 #2
0
 public void testCreateZFDApp()
 {
     LDAPZFDApp app = new LDAPZFDApp("cn=app1,ou=apps,o=KC");
     app.setCN("app1");
     Assert.AreSame("app1", app.getCN());
     Assert.AreSame("cn=app1,ou=apps,o=KC", app.getDN());
 }
コード例 #3
0
        public void TestZFDAppAssociation_ChangesNotFound()
        {
            LDAPZFDApp newApp = new LDAPZFDApp("cn=app1, ou=apps, o=kc");
            LDAPZFDApp existApp = new LDAPZFDApp("cn=app1, ou=apps, o=kc");
            List<string> newAssoc = new List<string>();
            List<string> oldAssoc = new List<string>();

            Console.WriteLine ("array1 count before {0}", newAssoc.Count);

            newAssoc.Add("cn=user1,ou=users,o=kc");
            oldAssoc.Add("cn=user1,ou=users,o=kc");

            newApp.setZENAppAssociations(newAssoc);
            existApp.setZENAppAssociations(oldAssoc);
            Console.WriteLine ("array1 count {0}", newAssoc.Count);
            Console.WriteLine ("array2 count {0}", oldAssoc.Count);
            ArrayList modlist = ZFDAppUtils.BuildZFDAppModifications(newApp, existApp);
            Assert.AreEqual(0,modlist.Count);
        }
コード例 #4
0
ファイル: LDAP.cs プロジェクト: ChristianRepo/sharpnldap
 /// <summary>
 /// Saves changes made to an existing ZFD 7 Application object
 /// </summary>
 /// <param name="app">
 /// A <see cref="LDAPZFDApp"/>
 /// </param>
 public void modifyZFDApp(LDAPZFDApp app)
 {
     ArrayList modList;
     LDAPZFDApp existingApp = getZFDApp(app.getDN());
     modList = ZFDAppUtils.BuildZFDAppModifications(app, existingApp);
     LdapModification[] mods = new LdapModification[modList.Count];
     Type mtype=Type.GetType("Novell.Directory.LdapModification");
     mods = (LdapModification[])modList.ToArray(typeof(LdapModification));
 }
コード例 #5
0
ファイル: AttributeUtil.cs プロジェクト: trepidity/sharpnldap
        /// <summary>
        /// Iterates the ZFD Application attributes
        /// </summary>
        /// <param name="attrSet">
        /// A <see cref="LdapAttributeSet"/>
        /// </param>
        /// <param name="dn">
        /// A <see cref="System.String"/>
        /// </param>
        /// <returns>
        /// A <see cref="LDAPGroup"/>
        /// </returns>
        public static LDAPZFDApp iterZFDAppAttrs(LdapAttributeSet attrSet, string dn)
        {
            LDAPZFDApp app;
            System.Collections.IEnumerator ienum =  attrSet.GetEnumerator();

            if (attrSet.Count == 0)
                return null;

            app = new LDAPZFDApp(dn);

            while(ienum.MoveNext())
            {
                LdapAttribute attribute=(LdapAttribute)ienum.Current;
                if (AttrEquals(attribute, ATTRNAME.APPASSOCIATIONS))
                    app.setAssociations(AttributeUtil.getListofAttr(attrSet, ATTRNAME.APPASSOCIATIONS));

            }
            return app;
        }
コード例 #6
0
        /// <summary>
        /// Compares current values in eDirectory with the values of the object that is to be written to eDirectory
        /// The results are returned as an LdapModifications array
        /// </summary>
        /// <param name="newApp">
        /// A <see cref="LDAPZFDApp"/>
        /// </param>
        /// <param name="oldApp">
        /// A <see cref="LDAPZFDApp"/>
        /// </param>
        /// <returns>
        /// A <see cref="LdapModification[]"/>
        /// </returns>
        internal static ArrayList BuildZFDAppModifications(LDAPZFDApp newApp, LDAPZFDApp oldApp)
        {
            LdapAttribute attribute;
            ArrayList modList = new ArrayList();

            /* If associations list do not match, replace */
            if (newApp.getZENAppAssociations().SequenceEqual(oldApp.getZENAppAssociations()) == false) {

                Logger.Debug("Current Associations and modified Associations do not match {0}", newApp.getDN());

                attribute = new LdapAttribute( "appAssociations", newApp.getZENAppAssociations().ToArray());
                modList.Add( new LdapModification(LdapModification.REPLACE, attribute)); //Add to the list of mods
            }

            return modList;
        }