1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Updating active directory using asp only?

Discussion in 'C#' started by astarter, Jun 11, 2007.

  1. #1
    Hi, i am a starter in this asp thing and currently working on a project to update user's property of MS outlook. I have written down this code to fetch user's property to show him in a user interface screen which i have made also.
    SEMrush
    option explicit
    DIM FLAG
    FLAG="false"
    DIM displayname,department,alias,company,email, address,title,city,state, zipcode, country,tel_ext, tel_off, tel_hom, tel_mob
    DIM rsTemp, adscon, com, strsql
    Set rsTemp = server.CreateObject("ADODB.Recordset")
    Set adscon = server.CreateObject("ADODB.connection")
    adscon.Provider = "ADsDSOObject"
    adscon.Properties("User ID") = Request.ServerVariables("Auth_User")
    adscon.Properties("Password") = Request.ServerVariables("Auth_Password")
    adscon.Properties("Encrypt Password") = true
    adscon.Open
    set com = server.CreateObject("ADODB.command")
    set com.ActiveConnection = adscon
    strsql = "SELECT Streetaddress,Postalcode,telephonenumber,company,c o,cn, title, department, mail, samAccountName, l, st FROM 'GC://ncorp-dc-01' where objectClass='User' and samAccountName = '" & Request.ServerVariables("Auth_User") &"'"
    com.CommandText = strsql
    Set rsTemp = com.execute(strsql)
    if rsTemp.RecordCount = 1 then
    displayname=rsTemp(6)
    alias=rsTemp(2)
    title=rsTemp(5)
    department=rsTemp(4)
    city=rsTemp(1)
    state=rsTemp(0)
    email=rsTemp(3)
    country=rsTemp(7)
    company=rsTemp(
    tel_off=rsTemp(9)
    zipcode=rsTemp(10)
    address=rsTemp(11)
    end if
    FLAG=TRIM(Request.Form("flag"))
    if FLAG="true" then
    Response.Write(tel_off & "<br>")
    tel_mob=TRIM(Request.form("tel_mob"))
    tel_ext=TRIM(Request.form("tel_ext"))
    tel_hom=TRIM(Request.form("tel_hom"))
    tel_off=TRIM(Request.form("tel_off"))
    end if

    Now Please tell, if I want to update user's phone no. only, then how to do so. Normal "Update set " command of sql is not working here. Please provide coding in asp only as I dont know the asp.Net thing.
    Hoping for some suggestions.
    thanking you
     
    astarter, Jun 11, 2007 IP
    SEMrush
  2. kashif.nazar

    kashif.nazar Peon

    Messages:
    52
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    its very simple, you have already done all the work.
    just go to your code here
    com.CommandText = strsql
    Set rsTemp = com.execute(strsql)
    here strsql should be
    strsql = update table set phonenumber = 123
    simple.
    It will work definately
     
    kashif.nazar, Jun 11, 2007 IP
  3. astarter

    astarter Guest

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    dude, thanks a lot for your help. But, what are you saying is perfectly valid for sql server and microsoft access.Not for active directory on exchange server on which i am working. It demands a whole lot of new techniques.

    Anyways, I have done it successfully somehow.

    @Admin: Please close this thread as my problem has been solved.
     
    astarter, Jun 12, 2007 IP
  4. ccoonen

    ccoonen Well-Known Member

    Messages:
    1,607
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    160
    #4
    well played astarter. yes, AD and SQL are 2 totally different beasts.
     
    ccoonen, Jun 14, 2007 IP