Thread: Permissions

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    10
    Rep Power
    0

    Permissions


    Hello everyone, i've been doing quite a bit of reading over the past week and cannot seem to find a remedy for my script. What i'm looking to do is add a user to an active directory group leveraging an existing classic asp page. I currently have an ID and pw with the proper credentials and am looking for an alternative to giving all who access the page admin rights.

    My script fails giving me the error `80072020` on the line:

    Set objGroup = GetObject("LDAP://CN=MOI-USERS-GS,OU=Applications,OU=Groups,DC=corporate,DC=corp,DC=com")

    Is it possible for me to establish credentials for this operation that would allow it to be carried out and how?

    here are the relevant pieces of the script in question:

    asp Code:
     
     
    <%
     
    Dim result, personFor, personBy
     
    	personFor = "Samuel J Link"
    	personBy = "Samuel J Link"
    	result = getDN(personFor)
     
    'Main
    		If isMember("MOI-USERS-GS")=1 Then  
    				response.write("Is member")	
     
    		Else
    				response.write("Is not a member")
     
    				Set objGroup = GetObject("LDAP://CN=MOI-USERS-GS,OU=Applications,OU=Groups,DC=corporate,DC=corp,DC=com")
    			    Set objUser = GetObject("LDAP://" & result)
    			    objGroup.add(objUser.ADspath) 					    
    		End If
     
    'Is member
    		Function IsMember(groupName)
    		    If IsEmpty(groupListD) then
    		        Set groupListD = CreateObject("Scripting.Dictionary")
    		        groupListD.CompareMode = 1
     
    				dim result
    				result = "Uid"
     
    		        ADpath = "Corporate" & "/" & result
    		        Set userPath = GetObject("WinNT://" & ADpath & ",user")
    		        For Each listGroup in userPath.Groups
    		            groupListD.Add listGroup.Name, "-"
    		        Next
    		    End if
    		    IsMember = CBool(groupListD.Exists(groupName))
    		End Function
     
    'get personFor DN	
    		Function getDN(name)
     
    			Dim adoCommand, adoConnection, strBase, strFilter, strAttributes
    			Dim objRootDSE, strDNSDomain, strQuery, adoRecordset, strsAM, objUser
     
     
    			Set adoConnection = CreateObject("ADODB.Connection")				
    				adoConnection.Provider = "ADsDSOObject"
    					With adoConnection
    						.Properties("User ID") = "PID"  'This is where the Process ID goes
    						.Properties("Password") = "PW"             'password
    						.Properties("encrypt password") = True
    					End With
     
    			adoConnection.Open "Active Directory Provider"
    			Set adoCommand = CreateObject("ADODB.Command")
    			Set adoCommand.ActiveConnection = adoConnection
     
     
    			Set objRootDSE = GetObject("LDAP://RootDSE")
    			strDNSDomain = objRootDSE.Get("defaultNamingContext")	
     
    			adoCommand.CommandText = "<LDAP://corporate.amfam.com>;(&(objectCategory=user)(CN=" & name & "));distinguishedName;subtree"
    			adoCommand.Properties("Page Size") = 100
    			adoCommand.Properties("Timeout") = 30
    			adoCommand.Properties("Cache Results") = False
     
    			Set adoRecordset = adoCommand.Execute
     
    			strsAM = adoRecordset.Fields("distinguishedName").Value
    			getDN= strsAM	
     
    			adoRecordset.Close
    			adoConnection.Close
    		End Function		
     
    %>


    thank you everyone for your assistance and time.
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    10
    Rep Power
    0

    got it


    Hey everyone, got the above code to work by using the:
    asp Code:
    Dim oGroup: Set oGroup = oDSObj.OpenDSObject


    now i'm attempting to append information to a csv but cant seem to get the file path specified correctly. does there appear to be anything wrong with this path? or is it just another permissions issue?? x_x

    asp Code:
    'output To CSV Log
    	sub outputToCSV (arg0, arg1, arg2)
     
    		Const ForAppending = 8 
     
    'change log to final destination
    		strFileOutput = "http://seconsec/seconsec/dev/sam/logs.csv"
     
    		Set objFSO = server.CreateObject("Scripting.FileSystemObject")
     
    		If objFSO.FileExists(strFileOutput) Then
    		  Set objOutputFile = objFSO.OpenTextFile (strFileOutput, 8)
    		Else
    		  Set objOutputFile = objFSO.CreateTextFile(strFileOutput)
    		  objOutputFile.Writeline "Date:" & "," & "Requested for:" & "," & "Requested By:" & "," & "Status of Request:"
    		End If
    		If Err <> 0 Then
    		  Wscript.Echo "Unable to open " & strFileOutput & " for output."
    		  WScript.Quit
    		End If
     
    		objOutputFile.Writeline Date()  & "," & arg0 & "," & arg1 & "," & arg2
     
    	End sub
  4. #3
  5. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,453
    Rep Power
    4539
    Thank you for updating the topic with your solution.
    ======
    Doug G
    ======
    Bartender to Rene Descartes "have another beer?" Descartes: "I think not" and he vanished.
    --Alfred Bester

IMN logo majestic logo threadwatch logo seochat tools logo