Setinfo resulting in a General Access Denied error

A little while back, I posted a nifty script to update AD from notes → https://www-10.lotus.com/ldd/nd6forum.nsf/ShowMyTopicsAllFlatweb/89727caefb8ca61b852571ef00607bb4?OpenDocument

Since presently I’m a Domain Admin, it runs great when I run it manually from my PC. If however I have it run on schedule on the server, I get the above error.

If I put my Domino server into the Domain Admins group, reboot, it works.

Since this is a pretty bad security risk, I’m trying to get the script to log in as me or a sufficiently privileged person. The code follows;

	Set conn = CreateObject("ADODB.Connection")

	conn.Provider = "ADsDSOObject"

	conn.Properties("User ID") = "MyDomain\MyUsername"

	conn.Properties("Password") = "MyPassword"

	Conn.Open

.

.

		Set Com = CreateObject("ADODB.Command")

		Set Com.ActiveConnection = Conn

		shortname = Doc.NetID(0)

’ We’ve read the Lifecycle document. We look up the person’s AD entry via the shortname

		Com.CommandText  = _

		"<LDAP://dc=iint>;(&(objectCategory=User)" & _

		"(sAMAccountName=" & shortname & "));distinguishedname,givenname,sn,manager,physicalDeliveryOfficeName,telephonenumber,pager,mobile,facsimileTelephoneNumber,title,department,company;subtree"

		Set RecordSet = com.execute

.

.

			dn = RecordSet.Fields("distinguishedname").value & ""

			physicalDeliveryOfficeName = RecordSet.Fields("physicalDeliveryOfficeName").Value & ""

.

.

			Set UserObject = GetObject("LDAP://" & dn)

.

.

			If physicalDeliveryOfficeName <> Doc.Location(0) Then

				AnyChange = True

				If Doc.Location(0) = "" Then

					UserObject.PutEx ADS_PROPERTY_CLEAR,"physicalDeliveryOfficeName", 0

				Else

					UserObject.put "physicalDeliveryOfficeName", Doc.location(0)

				End If

			End If

.

.

			If AnyChange = True Then

				Print "Updating " & dn

				UserObject.SetInfo

			End If

If I change the username or password to bogus values, I get a “Permission Denied” when I do the first com.execute command so I know the login is being correctly applied.

It’s as if I’m somehow loosing the login credentials by the time I get to the setinfo command and it reverts back to the server’s credentials…

Any ideas?

Subject: Setinfo resulting in a General Access Denied error

I found the solution in another post here. The germane part of the code!

Sub Click(Source As Button)

Dim dso As Variant

Dim obj1 As Variant

Const ADS_SECURE_AUTHENTICATION = &h1

Const ADS_SERVER_BIND = &h200 

Const ADS_FAST_BIND = &h20



dn = "LDAP://SomeADFullyQualifiedUsername"

Set dso = GetObject("LDAP:")

’ Supply full credentials to initiate a server connection.

Set obj1 = dso.OpenDSObject( _

dn, _

"YourADUsername", _

"YourADPassword",_

ADS_SECURE_AUTHENTICATION + ADS_FAST_BIND)



a=obj1.get("physicalDeliveryOfficeName")

End Sub