/// <summary> /// Overriden constructor gets all class schema attributes from AD Schema template /// </summary> /// <param name="container"></param> /// <param name="parentPage"></param> /// <param name="text"></param> /// <param name="schemaCache"></param> public ADObjectAddDlg(IPlugInContainer container, StandardPage parentPage, string text, LDAPSchemaCache schemaCache, ADUCDirectoryNode dirnode) : this() { this.IPlugInContainer = container; this.Text = text; string[] objectClasses = null; string[] attrs = { "name", "allowedAttributes", "allowedChildClasses", null }; if (schemaCache != null && dirnode != null) { List<LdapEntry> ldapEntries = null; int ret = dirnode.LdapContext.ListChildEntriesSynchronous (dirnode.DistinguishedName, LdapAPI.LDAPSCOPE.BASE, "(objectClass=*)", attrs, false, out ldapEntries); if (ldapEntries == null) { return; } LdapEntry ldapNextEntry = ldapEntries[0]; LdapValue[] ldapValues = ldapNextEntry.GetAttributeValues("allowedChildClasses", dirnode.LdapContext); if (ldapValues != null && ldapValues.Length > 0) { objectClasses = new string[ldapValues.Length]; int index = 0; foreach (LdapValue Oclass in ldapValues) { objectClasses[index] = Oclass.stringData; index++; } } } this.objectClasses = objectClasses; this.schemaCache = schemaCache; this.choosenClass = null; this.objectInfo = new ObjectInfo(); this.AddPage(new ObjectAddWelcomePage(this, dirnode, container, parentPage)); }
/// <summary> /// Overriden constructor gets all class schema attributes from AD Schema template /// </summary> /// <param name="container"></param> /// <param name="parentPage"></param> /// <param name="text"></param> /// <param name="schemaCache"></param> public ADObjectAddDlg(IPlugInContainer container, StandardPage parentPage, string text, LDAPSchemaCache schemaCache, ADUCDirectoryNode dirnode) : this() { this.IPlugInContainer = container; this.Text = text; string[] objectClasses = null; string[] attrs = { "name", "allowedAttributes", "allowedChildClasses", null }; if (schemaCache != null && dirnode != null) { List <LdapEntry> ldapEntries = null; int ret = dirnode.LdapContext.ListChildEntriesSynchronous (dirnode.DistinguishedName, LdapAPI.LDAPSCOPE.BASE, "(objectClass=*)", attrs, false, out ldapEntries); if (ldapEntries == null) { return; } LdapEntry ldapNextEntry = ldapEntries[0]; LdapValue[] ldapValues = ldapNextEntry.GetAttributeValues("allowedChildClasses", dirnode.LdapContext); if (ldapValues != null && ldapValues.Length > 0) { objectClasses = new string[ldapValues.Length]; int index = 0; foreach (LdapValue Oclass in ldapValues) { objectClasses[index] = Oclass.stringData; index++; } } } this.objectClasses = objectClasses; this.schemaCache = schemaCache; this.choosenClass = null; this.objectInfo = new ObjectInfo(); this.AddPage(new ObjectAddWelcomePage(this, dirnode, container, parentPage)); }
private bool BuildSchemaCache(bool usingSimpleBind) { if (_adContext == null) { return(false); } _adContext.SchemaCache = LDAPSchemaCache.Build(_adContext); _schemaCache = _adContext.SchemaCache; DirectoryEntry.exisitngDirContext.Add(_adContext); DirectoryEntry.existingSchemaCache.Add(_schemaCache); string sldapPath = string.Concat("LDAP://", _hn.domainName, "/", rootDN); ADUCDirectoryNode rootNode = ADUCDirectoryNode.GetDirectoryRoot( _adContext, _rootDN, Resources.ADUC, typeof(ADUCPage), _plugin); if (rootNode == null) { Logger.Log("The rootNode is null"); return(false); } _rootNode = rootNode; _shortDomainName = UserGroupUtils.getnetBiosName(rootNode); Logger.Log( "the obtained NetbiosName is " + _shortDomainName, Logger.ldapLogLevel); return(true); }
/// <summary> /// Method to load data to the tab pages while loading /// Gets all the tab pages that are of type MPage and gets call the SetData() /// Queries the ldap message to the selected node /// </summary> /// <param name="ce"></param> /// <param name="servername"></param> /// <param name="computer"></param> /// <param name="dirnode"></param> /// <param name="ldapSchemaCache"></param> public void SetData(CredentialEntry ce, string servername, string sOU, ADUCDirectoryNode dirnode, LDAPSchemaCache ldapSchemaCache) { Applied = false; _plugin = dirnode.Plugin as ADUCPlugin; this.Text = String.Format(this.Text, sOU); objInfo = new ObjectPropertyInfo (ce, servername, sOU, dirnode, null ); threadMain = new Thread(new ThreadStart(AddPagesToThread)); threadMain.Start(); _plugin.Propertywindowhandles.Add(objInfo.dirnode.DistinguishedName, this); }
/// <summary> /// Method to load data to the tab pages while loading /// Gets the all attribute list for the selected AD object by querying the Ldap Message. /// </summary> /// <param name="ce"></param> /// <param name="servername"></param> /// <param name="username"></param> /// <param name="dirNode"></param public void SetData(CredentialEntry ce, string servername, string username, ADUCDirectoryNode dirNode) { try { dirnode = dirNode; InitLdapMessage(); schemaCache = dirnode.LdapContext.SchemaCache; if (objectClasses != null && objectClasses.Length != 0) { MandatoryAttributes = new List<string>(); foreach (string objectClass in objectClasses) { LdapClassType classtype = schemaCache.GetSchemaTypeByObjectClass(objectClass) as LdapClassType; if (classtype != null && classtype.MandatoryAttributes != null) { foreach (string attr in classtype.MandatoryAttributes) { MandatoryAttributes.Add(attr); } } } if (dirnode.ObjectClass.Trim().Equals("user", StringComparison.InvariantCultureIgnoreCase) || dirnode.ObjectClass.Trim().Equals("group", StringComparison.InvariantCultureIgnoreCase) || dirnode.ObjectClass.Trim().Equals("computer", StringComparison.InvariantCultureIgnoreCase)) { MandatoryAttributes.Add("objectSid"); MandatoryAttributes.Add("sAMAccountName"); if (!MandatoryAttributes.Contains("cn")) { MandatoryAttributes.Add("cn"); } } } FillAttributeList(true, out _modifiedPageObject); ParentContainer.DataChanged = false; if (_modifiedPageObject != null) { _OriginalPageObject = (ADEditPageObject)_modifiedPageObject.Clone(); } else { _OriginalPageObject = new ADEditPageObject(); } UpdateApplyButton(); } catch (Exception e) { Logger.LogException("ADEditPage.SetData", e); } }
/// <summary> /// Method to load data to the tab pages while loading /// Gets all the tab pages that are of type MPage and get calls the SetData() /// Queries the ldap message to the selected node /// </summary> /// <param name="ce"></param> /// <param name="servername"></param> /// <param name="user"></param> /// <param name="dirnode"></param> /// <param name="ldapSchemaCache"></param> public void SetData(CredentialEntry ce, string servername, string user, ADUCDirectoryNode dirnode, LDAPSchemaCache ldapSchemaCache) { Applied = false; _plugin = dirnode.Plugin as ADUCPlugin; this.Text = String.Format(this.Text, user); objInfo = new ObjectPropertyInfo (ce, servername, user, dirnode, null ); threadMain = new Thread(new ThreadStart(AddPagesToThread)); threadMain.Start(); _plugin.Propertywindowhandles.Add(objInfo.dirnode.DistinguishedName, this); }
/// <summary> /// Method to load data to the tab pages while loading /// Gets all the tab pages that are of type MPage and gets call the SetData() /// Queries the ldap message to the selected node /// </summary> /// <param name="ce"></param> /// <param name="servername"></param> /// <param name="computer"></param> /// <param name="dirnode"></param> /// <param name="ldapSchemaCache"></param> public void SetData(CredentialEntry ce, string servername, string sOU, ADUCDirectoryNode dirnode, LDAPSchemaCache ldapSchemaCache) { Applied = false; _plugin = dirnode.Plugin as ADUCPlugin; objInfo = new ObjectPropertyInfo (ce, servername, sOU, dirnode, null); threadMain = new Thread(new ThreadStart(AddPagesToThread)); threadMain.Start(); }
/// <summary> /// Method to load data to the tab pages while loading /// Gets all the tab pages that are of type MPage and gets call the SetData() /// Queries the ldap message to the selected node /// </summary> /// <param name="ce"></param> /// <param name="servername"></param> /// <param name="computer"></param> /// <param name="dirnode"></param> /// <param name="ldapSchemaCache"></param> public void SetData(CredentialEntry ce, string servername, string computer, ADUCDirectoryNode dirnode, LDAPSchemaCache ldapSchemaCache) { string PageTitle = string.Format("cn={0}", _objectAddDlg.objectInfo.htMandatoryAttrList["cn"]); if (PageTitle != null) { this.Text = String.Format(this.Text, PageTitle); } if (this.GetPages() != null) { foreach (MPPage page in this.GetPages()) { if (page != null) { IDirectoryPropertiesPage ipp = page as IDirectoryPropertiesPage; if (ipp != null) { ipp.SetData(ce, servername, computer, dirnode); } } } } }
/// <summary> /// Method to load data to the tab pages while loading /// Gets all the tab pages that are of type MPage and gets call the SetData() /// Queries the ldap message to the selected node /// </summary> /// <param name="ce"></param> /// <param name="servername"></param> /// <param name="computer"></param> /// <param name="dirnode"></param> /// <param name="ldapSchemaCache"></param> public void SetData(CredentialEntry ce, string servername, string computer, ADUCDirectoryNode dirnode, LDAPSchemaCache ldapSchemaCache) { string PageTitle = string.Format("cn={0}", _objectAddDlg.objectInfo.htMandatoryAttrList["cn"]); if (PageTitle != null) { this.Text = String.Format(this.Text, PageTitle); } if (this.GetPages() != null) { foreach (MPPage page in this.GetPages()) { if (page != null) { IDirectoryPropertiesPage ipp = page as IDirectoryPropertiesPage; if (ipp != null) { ipp.SetData(ce, servername, computer, dirnode); } } } } }
private DirectoryContext Assign_dirContext() { if (dirContext == null) { if (sProtocol.Equals("GC", StringComparison.InvariantCultureIgnoreCase)) { if (!findDircontext(GC_PORT)) { //Console.WriteLine("****************Creating GC directoryContext*******************"); if (findGCServer() != null) { sServer = findGCServer(); } string errorMessage = null; dirContext = DirectoryContext.CreateDirectoryContext( sServer, rootDN, this.sUsername, this.sPassword, GC_PORT, findBindingMethod(), out errorMessage); if (dirContext != null) { //Console.WriteLine("-------------Global catalog DirectoryContext is created.--------------------"); exisitngDirContext.Add(dirContext); if (!FindSchemaCache()) { dirContext.SchemaCache = LDAPSchemaCache.Build(dirContext); existingSchemaCache.Add(dirContext.SchemaCache); } } } } else if (sProtocol.Equals("LDAP", StringComparison.InvariantCultureIgnoreCase)) { if (!findDircontext(LDAP_PORT)) { string errorMessage = null; //Console.WriteLine("****************Creating Normal Ldap directoryContext*******************"); dirContext = DirectoryContext.CreateDirectoryContext( sServer, rootDN, this.sUsername, this.sPassword, LDAP_PORT, findBindingMethod(), out errorMessage); if (dirContext != null) { //Console.WriteLine("-------------------Normal LDAP DirectoryContext is created.--------------------"); exisitngDirContext.Add(dirContext); //Console.WriteLine("dircontext portnumber is " + dirContext.PortNumber + dirContext.LdapHandle); if (!FindSchemaCache()) { dirContext.SchemaCache = LDAPSchemaCache.Build(dirContext); existingSchemaCache.Add(dirContext.SchemaCache); } } } } } if (dirContext == null) { throw new Exception("Create DirectoryContext Failed - logon failure: Unknown Username or Bad password."); } else { return(dirContext); } }
/// <summary> /// Method to load data to the tab pages while loading /// Gets all the tab pages that are of type MPage and gets call the SetData() /// Queries the ldap message to the selected node /// </summary> /// <param name="ce"></param> /// <param name="servername"></param> /// <param name="computer"></param> /// <param name="dirnode"></param> /// <param name="ldapSchemaCache"></param> public void SetData(CredentialEntry ce, string servername, string sOU, ADUCDirectoryNode dirnode, LDAPSchemaCache ldapSchemaCache) { Applied = false; _plugin = dirnode.Plugin as ADUCPlugin; objInfo = new ObjectPropertyInfo (ce, servername, sOU, dirnode, null); threadMain = new Thread(new ThreadStart(AddPagesToThread)); threadMain.Start(); }
private bool BuildSchemaCache(bool usingSimpleBind) { if (_adContext == null) { return false; } _adContext.SchemaCache = LDAPSchemaCache.Build(_adContext); _schemaCache = _adContext.SchemaCache; DirectoryEntry.exisitngDirContext.Add(_adContext); DirectoryEntry.existingSchemaCache.Add(_schemaCache); string sldapPath = string.Concat("LDAP://", _hn.domainName, "/", rootDN); ADUCDirectoryNode rootNode = ADUCDirectoryNode.GetDirectoryRoot( _adContext, _rootDN, Resources.ADUC, typeof(ADUCPage), _plugin); if (rootNode == null) { Logger.Log("The rootNode is null"); return false; } _rootNode = rootNode; _shortDomainName = UserGroupUtils.getnetBiosName(rootNode); Logger.Log( "the obtained NetbiosName is " + _shortDomainName, Logger.ldapLogLevel); return true; }