BindAs Method

The BindAs method sets the ADSI binding credentials used when binding to ADSI objects defined by the specified Active User Object (AUO) provider alias.

IDL Definition

[id(5)] HRESULT BindAs(
BSTR bszAlias,
BSTR bszUserName,
BSTR bszPassword
);

Parameters

bszAlias

The AUO alias to set binding credentials for.

bszUserName

The name to use when binding.  This name should be a distinguished name. (e.g. "c=us/o=comp/ou=admin/cn=admin")

bszPassword

The password to use when binding.

Return Values

a standard HRESULT value.

Remarks

The Init or InitEx method must be called first before any other methods are invoked on objects of class SchemaObjects.  If one uses the built-in ASP object Server to create the object via its CreateObject method, Init is called automatically in the ISchemaObjects OnStartPage callback method invoked by the ASP scripting context.

The BindAs method can only be invoked prior to any binding of ADSI objects.  If an ADSI object has been bound, the method will return a COM exception.

One can permanently set the binding credentials using the BindAsName and BindAsPassword values for the AUO provider definition.

Example

ASP and VBScript

<%
Set ISchemaObjects = Server.CreateObject("Membership.SchemaObjects")
BindUser = "c=US/o=company/ou=members/cn=Administrator"
BindPwd = "password"
call ISchemaObjects.BindAs( BindUser, BindPwd )
%>

See Also

Init

Class AuoConfig


© 1997-1998 Microsoft Corporation. All rights reserved.