ASP.NET blog

25 11 2009

My friend Mike has posted a blog with quite a few ASP.NET tips. Check it out:

http://myfishingstream.blogspot.com/

Go grab WebDeveloper 2008 from Microsoft and happy coding!

http://www.microsoft.com/express/vwd/





unlock account in a/d

9 11 2009

Const ADS_PROPERTY_CLEAR = 1
Const ADS_PROPERTY_UPDATE = 2
Const ADS_PROPERTY_APPEND = 3
Const ADS_PROPERTY_DELETE = 4

samaccountname=request.querystring("namer")

Dim oRootDSE, oCon, oCmd, oRecordSet
Dim sDomainADsPath, sUser, sPassword, sGroup, sProperties
Dim aDescription, aMember, iCount

Set oRootDSE = GetObject("LDAP://RootDSE")
sDomainADsPath = "LDAP://" & oRootDSE.Get("defaultNamingContext")
Set oRootDSE = Nothing

Set oCon = Server.CreateObject("ADODB.Connection")

sUser = "xx\corpdirectory"
sPassword = "xxx"

oCon.Provider = "ADsDSOObject"

oCon.Open "ADProvider", sUser, sPassword

Set oCmd = Server.CreateObject("ADODB.Command")
Set oCmd.ActiveConnection = oCon

sProperties = "samaccountname,cn,facsimileTelephoneNumber,distinguishedName,displayname"
'sGroup = "bjones"
oCmd.CommandText = ";(&(objectCategory=user)(samaccountname=" & samaccountname & "));" & sProperties & ";subtree"

'oCmd.CommandText = ";(&(objectCategory=user)(facsimileTelephoneNumber=" & namer & "));" & sProperties & ";subtree"
oCmd.Properties("Page Size") = 100

Set oRecordSet = oCmd.Execute

While Not oRecordSet.EOF

'connx = "WINNT://" & "NETWASATCH" & "/" & oRecordSet.Fields("samaccountname")
connx = "LDAP://" & oRecordSet.Fields("distinguishedName")

set usr = GetObject(connx)

usr.put "lockouttime","0"
usr.SetInfo

oRecordset.movenext
wend

bbb = "display.asp?namer=" & samaccountname

response.redirect bbb





resetpw in a/d

9 11 2009

Const ADS_PROPERTY_CLEAR = 1
Const ADS_PROPERTY_UPDATE = 2
Const ADS_PROPERTY_APPEND = 3
Const ADS_PROPERTY_DELETE = 4

namer = request.form("namer")
pwd = request.form("pwd")
'namer = "TESTBRETT"

Dim oRootDSE, oCon, oCmd, oRecordSet
Dim sDomainADsPath, sUser, sPassword, sGroup, sProperties
Dim aDescription, aMember, iCount

Set oRootDSE = GetObject("LDAP://RootDSE")
sDomainADsPath = "LDAP://" & oRootDSE.Get("defaultNamingContext")
Set oRootDSE = Nothing

Set oCon = Server.CreateObject("ADODB.Connection")

sUser = "xx\corpdirectory"
sPassword = "xxx"

oCon.Provider = "ADsDSOObject"

oCon.Open "ADProvider", sUser, sPassword

Set oCmd = Server.CreateObject("ADODB.Command")
Set oCmd.ActiveConnection = oCon

sProperties = "cn,facsimileTelephoneNumber,distinguishedName,displayname"
'sGroup = "bjones"
oCmd.CommandText = ";(&(objectCategory=user)(samaccountname=" & namer & "));" & sProperties & ";subtree"

'oCmd.CommandText = ";(&(objectCategory=user)(facsimileTelephoneNumber=" & namer & "));" & sProperties & ";subtree"
oCmd.Properties("Page Size") = 100

Set oRecordSet = oCmd.Execute

While Not oRecordSet.EOF

connx = "LDAP://" & oRecordSet.Fields("distinguishedName")

set usr = GetObject(connx)

usr.SetPassword(pwd)

oRecordset.movenext
wend

bbb = "default.asp?namer=" & samaccountname

response.redirect bbb
'response.write(namer & "|" & pwd)





update a/d user

9 11 2009

Const ADS_PROPERTY_CLEAR = 1
Const ADS_PROPERTY_UPDATE = 2
Const ADS_PROPERTY_APPEND = 3
Const ADS_PROPERTY_DELETE = 4

title = request.form("title")
department = request.form("department")
physicalDeliveryOfficeName = request.form("physicalDeliveryOfficeName")
mail = request.form("mail")
telephoneNumber = request.form("telephoneNumber")
mobile = request.form("mobile")
ipPhone = request.form("ipPhone")
pager = request.form("pager")
facsimileTelephoneNumber = request.form("facsimileTelephoneNumber")
wwwHomePage = request.form("wwwHomePage")
homePhone = request.form("homePhone")
streetAddress = request.form("streetAddress")
postOfficeBox = request.form("postOfficeBox")
l = request.form("l")
st = request.form("st")
postalCode = request.form("postalCode")
description = request.form("description")

samaccountname = request.form("samaccountname")

Dim oRootDSE, oCon, oCmd, oRecordSet
Dim sDomainADsPath, sUser, sPassword, sGroup, sProperties
Dim aDescription, aMember, iCount

Set oRootDSE = GetObject("LDAP://RootDSE")
sDomainADsPath = "LDAP://" & oRootDSE.Get("defaultNamingContext")
Set oRootDSE = Nothing

Set oCon = Server.CreateObject("ADODB.Connection")

sUser = "netwasatch\corpdirectory"
sPassword = "wasatch"

oCon.Provider = "ADsDSOObject"

oCon.Open "ADProvider", sUser, sPassword

Set oCmd = Server.CreateObject("ADODB.Command")
Set oCmd.ActiveConnection = oCon

sProperties = "cn,facsimileTelephoneNumber,distinguishedName,displayname"
'sGroup = "xxx"
oCmd.CommandText = ";(&(objectCategory=user)(samaccountname=" & samaccountname & "));" & sProperties & ";subtree"

'oCmd.CommandText = ";(&(objectCategory=user)(facsimileTelephoneNumber=" & namer & "));" & sProperties & ";subtree"
oCmd.Properties("Page Size") = 100

Set oRecordSet = oCmd.Execute

While Not oRecordSet.EOF

connx = "LDAP://" & oRecordSet.Fields("distinguishedName")

'response.write(connx)
set usr = GetObject(connx)
'usr.Put "facsimileTelephoneNumber", "8887552045"

if title "" then
usr.Put "title",title
else
usr.PutEx ADS_PROPERTY_CLEAR, "title", 0
end if

if department "" then
usr.Put "department",department
else
usr.PutEx ADS_PROPERTY_CLEAR, "department", 0
end if

if physicalDeliveryOfficeName "" then
usr.Put "physicalDeliveryOfficeName",physicalDeliveryOfficeName
else
usr.PutEx ADS_PROPERTY_CLEAR, "physicalDeliveryOfficeName", 0
end if

if mail "" then
usr.Put "mail",mail
else
usr.PutEx ADS_PROPERTY_CLEAR, "mail", 0
end if

if telephoneNumber "" then
usr.Put "telephoneNumber",telephoneNumber
else
usr.PutEx ADS_PROPERTY_CLEAR, "telephoneNumber", 0
end if

if mobile "" then
usr.Put "mobile",mobile
else
usr.PutEx ADS_PROPERTY_CLEAR, "mobile", 0
end if

if ipPhone "" then
usr.Put "ipPhone",ipPhone
else
usr.PutEx ADS_PROPERTY_CLEAR, "ipPhone", 0
end if

if pager "" then
usr.Put "pager",pager
else
usr.PutEx ADS_PROPERTY_CLEAR, "pager", 0
end if

if facsimileTelephoneNumber "" then
usr.Put "facsimileTelephoneNumber",facsimileTelephoneNumber
else
usr.PutEx ADS_PROPERTY_CLEAR, "facsimileTelephoneNumber", 0
end if

if wwwHomePage "" then
usr.Put "wwwHomePage",wwwHomePage
else
usr.PutEx ADS_PROPERTY_CLEAR, "wwwHomePage", 0
end if

if homePhone "" then
usr.Put "homePhone",homePhone
else
usr.PutEx ADS_PROPERTY_CLEAR, "homePhone", 0
end if

if streetAddress "" then
usr.Put "streetAddress",streetAddress
else
usr.PutEx ADS_PROPERTY_CLEAR, "streetAddress", 0
end if

if description "" then
Dim arrayValues1(0)
arrayValues1(0) = description
usr.PutEx ADS_PROPERTY_UPDATE, "description", arrayValues1
else
usr.PutEx ADS_PROPERTY_CLEAR, "description", 0
end if

if postOfficeBox "" then
Dim arrayValues(0)
arrayValues(0) = postOfficeBox
usr.PutEx ADS_PROPERTY_UPDATE, "postOfficeBox", arrayValues
else
usr.PutEx ADS_PROPERTY_CLEAR, "postOfficeBox", 0
end if

if l "" then
usr.Put "l",l
else
usr.PutEx ADS_PROPERTY_CLEAR, "l", 0
end if

if st "" then
usr.Put "st",st
else
usr.PutEx ADS_PROPERTY_CLEAR, "st", 0
end if

if postalCode "" then
usr.Put "postalCode",postalCode
else
usr.PutEx ADS_PROPERTY_CLEAR, "postalCode", 0
end if

usr.SetInfo

oRecordset.movenext
wend

bbb = "self.asp"

response.redirect bbb





ajax

9 11 2009


//globals
var first = "topic"; //id of first SELECT
var second = "callconsultant"; //id of second SELECT
var third = "fullname";
//
function sendRequest(url,params,HttpMethod) {
if(!HttpMethod) { //check if http method is defined, if not, set it to GET
HttpMethod="GET";
}
//
// initialize request object
req=null;
if(window.XMLHttpRequest){
req=new XMLHttpRequest; //mozilla/safari
} else if(window.ActiveXObject){
req=new ActiveXObject("Microsoft.XMLHTTP"); //internet explorer
}
//
//define callback handler
if(req) {
//
req.onreadystatechange=onReadyState;
req.open(HttpMethod,url,true);
req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
req.send(params);
}
}
//
function onReadyState() {
//
var ready=req.readyState;
var data=null;
if(ready==4){ //check ready state
data=req.responseText; //read response data
var spliff = data.split(';')

var items = data.split(',');
var length = items.length;
for(var i = 1; i "Select topic first"
sendRequest('fetch.asp?topic='+el.options[selected].value);
ob2.disabled=0;
} else { //otherwise add the Select Topic First option and disable it
var childEl = document.createElement('option');
ob2.appendChild(childEl);
childEl.innerHTML = 'Select Date First';
ob2.disabled=1;
}
}

function clicked2() {
//
var el=document.getElementById(first);
var el1=document.getElementById(second);
var ob2=document.getElementById(third);
var selected1 = el.selectedIndex;
var selected2 = el1.selectedIndex;

//
while(ob2.hasChildNodes()) { //removes items from dropdown if some already exist
ob2.removeChild(ob2.firstChild);
}
if(selected2!= 0) { //if they choose something other than the first select-->"Select topic first"
var bob = 'fetch2.asp?topic='+el.options[selected1].value+'&fullname='+el1.options[selected2].value
sendRequest(bob);
ob2.disabled=0;
} else { //otherwise add the Select Topic First option and disable it
var childEl = document.createElement('option');
ob2.appendChild(childEl);
childEl.innerHTML = 'Select Date First';
ob2.disabled=1;
}
}





snipplr

9 11 2009

http://snipplr.com/

cool code snippet site.





ASPX HitCounter

12 10 2009

Had to rewrite my Hit Counter for ASPX.

dim authuser
dim pager
dim myconn
dim connstring
dim selecter
dim listy
dim bongo
dim inserter
dim listy1
dim sel
dim listy2
dim numb
dim writer
dim listy3
dim s1
dim s2
dim s3
dim s4
dim s5
dim s6
dim area51
dim area52
dim r1
dim r2

authuser = ChkEmailuserToCheck
pager = "home"

MyConn=Server.CreateObject("ADODB.Connection")
connstring="Provider=SQLOLEDB.1;Password=hedgehog;Persist Security Info=False;User ID=websrv;Initial Catalog=websrv;Data Source=yardibck"
MyConn.Open(connstring)

selecter = "select Count(authname) as countr from Names where authname ='" & authuser & "';"
listy = MyConn.Execute(selecter)
bongo = listy("countr").value

if bongo = 0 then

inserter = "Insert into Names (authname, logins, pager, dater) values ('" & authuser & "', '1', 'default', '" & now() & "');"
listy1 = MyConn.Execute(inserter)

else

sel = "select logins as logger from Names where authname = '" & authuser & "';"
listy2 = MyConn.Execute(sel)

numb = listy2("logger").value

numb = numb + 1

writer = "update names set logins = '" & numb & "', dater = '" & now() & "' where authname = '" & authuser & "';"
listy3 = MyConn.Execute(writer)

end if

s1 = "select count(dater) as dtr from names1 where datediff(d, dater, getdate()) = '0'"
s2 = MyConn.Execute(s1)
if s2("dtr").value = 0 then
s3 = "insert into names1 (dater, counter) values ('" & now() & "','1')"
s4 = MyConn.Execute(s3)
else

r1 = "select counter from names1 where datediff(d, dater, getdate()) = '0'"
r2 = MyConn.execute(r1)

area51 = r2("counter").value
area52 = area51 + 1
s5 = "update names1 set counter = '"& area52 & "';"
s6 = MyConn.execute(s5)

end if





ajax nested dropdown boxes

6 10 2009

// <![CDATA[
//globals
var first = "topic"; //id of first SELECT
var second = "callconsultant"; //id of second SELECT
var third = "fullname";
//
function sendRequest(url,params,HttpMethod) {
if(!HttpMethod) { //check if http method is defined, if not, set it to GET
HttpMethod="GET";
}
//
// initialize request object
req=null;
if(window.XMLHttpRequest){
req=new XMLHttpRequest; //mozilla/safari
} else if(window.ActiveXObject){
req=new ActiveXObject("Microsoft.XMLHTTP"); //internet explorer
}
//
//define callback handler
if(req) {
//
req.onreadystatechange=onReadyState;
req.open(HttpMethod,url,true);
req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
req.send(params);
}
}
//
function onReadyState() {
//
var ready=req.readyState;
var data=null;
if(ready==4){ //check ready state
data=req.responseText; //read response data
var spliff = data.split(';')

var items = data.split(',');
var length = items.length;
for(var i = 1; i "Select topic first"
sendRequest('fetch.asp?topic='+el.options[selected].value);
ob2.disabled=0;
} else { //otherwise add the Select Topic First option and disable it
var childEl = document.createElement('option');
ob2.appendChild(childEl);
childEl.innerHTML = 'Select Date First';
ob2.disabled=1;
}
}

function clicked2() {
//
var el=document.getElementById(first);
var el1=document.getElementById(second);
var ob2=document.getElementById(third);
var selected1 = el.selectedIndex;
var selected2 = el1.selectedIndex;

//
while(ob2.hasChildNodes()) { //removes items from dropdown if some already exist
ob2.removeChild(ob2.firstChild);
}
if(selected2!= 0) { //if they choose something other than the first select-->"Select topic first"
var bob = 'fetch2.asp?topic='+el.options[selected1].value+'&fullname='+el1.options[selected2].value
sendRequest(bob);
ob2.disabled=0;
} else { //otherwise add the Select Topic First option and disable it
var childEl = document.createElement('option');
ob2.appendChild(childEl);
childEl.innerHTML = 'Select Date First';
ob2.disabled=1;
}
}





Boules in Logan

23 10 2008

I’ve just created a new website about building a Petanque Piste in Logan UT

http://mosaiclogan.blogspot.com/





4 08 2007

kifkif.jpg

Been working on the kif kif website a bit more.  Added a nice FavIcon to the site and finally fixed my google video bar problem.  The google .js files didn’t like that I had saved my html file as Unicode instead of UTF-8 in firefox.  Once I changed that it all worked again.  Pretty happy with the site to be very honest am deciding the best way to embed some mp3s at the current time.

http://kifkif.fft.googlepages.com/kif.htm 

Went to Paleo festival last week, saw both Rachid Taha and Tinariwen.  A great time was had by all.  They had a nice little nomad area set up with an earthen oven and nomad tents.  Christa bought a very cool blue shirt from one of the fellows.  Audrey loved it, especially all the Harira soup she ate at the Moroccan restaurant.  That’s right, they had a real restaurant at the festival, served in Tajines and everything.  Very impressed.

 http://www.paleo.ch/live/paleo/home/live/live_concerts.php?&day=20070728








Follow

Get every new post delivered to your Inbox.