Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

script to clear mapped drives in AD

Status
Not open for further replies.

Seaspray0

Technical User
Jan 27, 2003
1,037
US
I need a script to clear the drive mapping under the profile tab for all users "connect x to ..." I do not need either a home folder or a drive mapping here.

Start, Help. You'll be surprised what's there. A+/MCP/MCSE/MCDBA
 
I've used LDP.EXE to examine the properties, I'll post the clips of the section in question.

What I need is:

1> codePage: 0;
1> countryCode: 840;
1> badPasswordTime: 3/15/2006 13:9:12 Central Standard Time Central Daylight Time;
1> lastLogoff: 0;

What I have:

1> codePage: 0;
1> countryCode: 840;
1> homeDirectory: \\fileserver\share;
1> homeDrive: H:;
1> badPasswordTime: 3/15/2006 13:9:12 Central Standard Time Central Daylight Time;
1> lastLogoff: 0;

I need a script to clear the "homeDirectory" and "homeDrive" elements from the user profile. I've already tried:

Set objUser = GetObject _
("LDAP://CN=TestUser,OU=My Users,OU=My Company,DC=mydomain,DC=com")

objUser.PutEx ADS_PROPERTY_CLEAR, "homeDirectory", 0
objUser.PutEx ADS_PROPERTY_CLEAR, "homeDrive", 0
objUser.SetInfo

No luck.

Start, Help. You'll be surprised what's there. A+/MCP/MCSE/MCDBA
 
Try this:

objUser.Put "homeDirectory", ""
objUser.Put "homeDrive", ""
objUser.SetInfo


I hope you find this post helpful.

Regards,

Mark
 
I gave it a try and no luck, mark. I can set it easily with a script, but I can't get it to erase.

Start, Help. You'll be surprised what's there. A+/MCP/MCSE/MCDBA
 
Have you defined the constant ads_property_clear (1) explicitly somewhere?
[tt]
[green]const ADS_PROPERTY_CLEAR=1[/green]
'etc...
objUser.PutEx ADS_PROPERTY_CLEAR, "homeDirectory", [red]""[/red]
objUser.PutEx ADS_PROPERTY_CLEAR, "homeDrive", [red]""[/red]
objUser.SetInfo
[/tt]
 
That got it, tsuji.

'Clear the homedrive mapping for TestUser
const ADS_PROPERTY_CLEAR=1
Set objUser = GetObject _
("LDAP://CN=TestUser,OU=My Users,OU=My Company,DC=mydomain,DC=com")
objUser.PutEx ADS_PROPERTY_CLEAR, "homeDrive", ""
objUser.PutEx ADS_PROPERTY_CLEAR, "homeDirectory", ""
objUser.SetInfo

All I have to do now is expand it to do all the users. I'm digging through the scriptcenter.exe as well as looking elsewhere here.

Start, Help. You'll be surprised what's there. A+/MCP/MCSE/MCDBA
 
My FAQ should help you use this against all of the users. faq329-4871

I hope you find this post helpful.

Regards,

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top