Monday, 21 January 2008

Active Directory: Query catalogue 2

Hoping to keep commonly used functions in this solution. The Common project now contains a User and ActiveDirectory object.

The User class returns commonly accessed attributes for a particular user via DirectoryServices.

The ActiveDirectory class contains commonly used functions to access AD. For example:

ConnectToActiveDirectory()
GetActiveDirectoryUser(string)
GetActiveDirectoryUsers()
GetActiveDirectoryUsers(DropDownList)
GetAttributes(Common.User)

It currently contains the connection properties to access AD and this should eventually be moved into a config file. Also a service account would need to be created as it currently uses my login details.

A web front end test harness have been setup as a separate project to test these functions.

Monday, 14 January 2008

Active Directory: Query catalogue

Begin development to enumerate all active users from ERGON's AD to a web front end. ERGON's AD contains nearly 7000 records in the CN - SOE users. This proved extremely slow using DirectoryServices. To enumerate the entire list took 1min10secs. Noticed that if you return 1000 records it took approx 3 seconds. The delay grows exponentially as the number of records increases.

Have discussed this finding with Alton. Proposed we create a subset of the data in AD for users and replicate this to a SQL database to speed up information retrieval. Alton agrees and further suggests he will look into ways of creating a trigger which updates SQL whenever AD is updated.

Spoke to Paul James. Currently the only Energex's GC contains both Ergon and Energex user details. This will eventually needs to be shifted to the SPARQ domain as it makes little sense to keep Ergon users in the Energex's domain. Spoke to Alton about this as well.

*Update*
Changed value for pagesize in directorysearcher. This increased the speed with which data was retrieve from AD. 7000 records are now returned in 4 secs. This is still slow and we will look into the SQL option.

Monday, 7 January 2008

Active Directory: Research

Research into .Net's DirectoryServices namespace and its interaction with ADSI - Active Directory Service Interface. Read up through Safari O'Reilly account (seems to be expired now, I cannot access the full chapter). Recommend this book: The .NET Developer's Guide to Directory Services Programming by Joe Kaplan; Ryan Dunn Begin development of the AD connector that abstracts and return a USER object from AD. This will allow the User object to eventually bind to either an AD or SQL backend.

Monday, 12 November 2007

HTML: Auto Adjust IFRAMEs

Auto Adjust IFRAME
------------------
<iframe name="ifr" id="ifr" src="whatever.html" onload="this.style.height 
= ifr.document.body.scrollHeight + 5"></iframe> 

OR

<iframe id="ifr" src="ifr.html">< /iframe>< br />
<input type="button" onclick="document.getElementById('ifr').style.height 
= ifr.document.body.scrollHeight + 5" value="Ajust" />

Sunday, 30 September 2007

TSQL: Delete duplicate rows which have the same primary key

--Delete Duplicate Rows
set rowcount 1
delete from hrerequestforapproval
where hrerequestforapprovalid=40508508

TSQL: Get Duplicate Rows Count

--Get Duplicate Row Counts
SELECT hrerequestforapprovalid, count(*)
FROM hrerequestforapproval
GROUP BY hrerequestforapprovalid
HAVING count(*) > 1

Friday, 24 August 2007

HTML: Mailto with CC, Subject, Body prepopulated

<a href="mailto:your.nominateduser@yahoo.com.au?cc=your.nominateduser@yahoo.com.au&subject=A new request&body=Please kindly complete the details below:%0D%0A%0D%0AName:%0D%0ATitle:%0D%0ALocation:%0D%0APhone:%0D%0AMobile:%0D%0A">Click here to email</a>

Wednesday, 15 August 2007

Javascript: Replacing OnLoad attribute in Body tag

//This section runs the SetPage function when the form loads - replaces OnLoad function in body tag
addLoadEvent(SetPage);
function addLoadEvent(func) {   
   var oldonload = window.onload;   
   if (typeof window.onload != 'function') {   
     window.onload = func;   
   } else {   
     window.onload = function() {   
       oldonload();   
       func();   
     }   
  }   
}

//Another example will run when page load but code doesn't utilize onLoad attribute in body tag
var frm = document.frmCreateModifyPosition;
window.onload = function(){
if (frm.txtAction[1].checked){
ShowPositionID()
}
}

Wednesday, 21 March 2007

TSQL: ALTER TABLE

--Alter table
ALTER TABLE MyTable ALTER COLUMN NullCOl NVARCHAR(20) NOT NULL
ALTER TABLE doc_exa ADD column_b VARCHAR(20) NULL
ALTER TABLE doc_exb DROP COLUMN column_b
ALTER TABLE doc_exc ADD column_b VARCHAR(20) NULL CONSTRAINT exb_unique UNIQUE
ALTER TABLE doc_exd WITH NOCHECK ADD CONSTRAINT exd_check CHECK (column_a > 1)

Friday, 9 March 2007

TSQL: UPDATE from values across server via Linked Server

You'll need to setup a linked server first in Enterprise Manager. This is found under Security > Linked Servers. Right click and select "New Linked Server", follow prompts to complete.


Update Dest
SET helpdefinitiontext = T.helpdefinitiontext
From
[erokwis99\dev].mis.dbo.measure as Dest Join
mis.dbo.measure as T On
Dest.measureid = T.measureid